Package org.apache.solr.client.solrj

Examples of org.apache.solr.client.solrj.SolrQuery.addFilterQuery()


    if (queryString.endsWith(AND))
      queryString = queryString.substring(0, queryString.length() - AND.length());
    query.setQuery(queryString);

    //filter to search only documents belonging to current user
    query.addFilterQuery(ProtocolConstants.KEY_USER_NAME + ':' + ClientUtils.escapeQueryChars(req.getRemoteUser()));

    //other common fields
    setField(req, query, CommonParams.ROWS);
    setField(req, query, CommonParams.START);
    setField(req, query, CommonParams.SORT);
View Full Code Here


            solrQuery.setRows(max);
            if (orderfield != null) {
                solrQuery.setSortField(orderfield, ascending ? SolrQuery.ORDER.asc : SolrQuery.ORDER.desc);
            }
            if (filterquery != null) {
                solrQuery.addFilterQuery(filterquery);
            }
            QueryResponse rsp = getSolr().query(solrQuery);
            SolrDocumentList docs = rsp.getResults();

            Iterator iter = docs.iterator();
View Full Code Here

        // performance and ensure the search result ordering will
        // not be influenced

        // Choose to filter by the Legacy spider IP list (may get too long to properly filter all IP's
        if(ConfigurationManager.getBooleanProperty("solr.statistics.query.filter.spiderIp",false))
            solrQuery.addFilterQuery(getIgnoreSpiderIPs());

        // Choose to filter by isBot field, may be overriden in future
        // to allow views on stats based on bots.
        if(ConfigurationManager.getBooleanProperty("solr.statistics.query.filter.isBot",true))
            solrQuery.addFilterQuery("-isBot:true");
View Full Code Here

            solrQuery.addFilterQuery(getIgnoreSpiderIPs());

        // Choose to filter by isBot field, may be overriden in future
        // to allow views on stats based on bots.
        if(ConfigurationManager.getBooleanProperty("solr.statistics.query.filter.isBot",true))
            solrQuery.addFilterQuery("-isBot:true");

        if (filterQuery != null)
            solrQuery.addFilterQuery(filterQuery);

        QueryResponse response = null;
View Full Code Here

        // to allow views on stats based on bots.
        if(ConfigurationManager.getBooleanProperty("solr.statistics.query.filter.isBot",true))
            solrQuery.addFilterQuery("-isBot:true");

        if (filterQuery != null)
            solrQuery.addFilterQuery(filterQuery);

        QueryResponse response = null;
        try
        {
            // solr.set
View Full Code Here

    private SolrQuery initSolrQuery(Query entityhubQuery) {
        SolrQuery query = new SolrQuery();
        // first add a filterquery for the domain if present
        if (domain != null) {
            query.addFilterQuery(String.format("%s:%s", fieldMapper.getDocumentDomainField(),
                SolrUtil.escapeSolrSpecialChars(domain)));
        }
        // than add the offset
        query.setStart(entityhubQuery.getOffset());
        // and the limit
View Full Code Here

    @Test public void withOtherFilters() throws Exception {
        addStandardFixtures();
        final SolrQuery query = new SolrQuery();
        query.add("spatial", "{!radius=15}40.7142691, -74.0059729");
        query.addFilterQuery("rating:4.0");
        assertResults(query, "New York", "Staten Island");
    }

    @Test public void simpleDistanceSorting() throws Exception {
        addStandardFixtures();
View Full Code Here

    @Test public void sortingWithOtherFilters() throws Exception {
        addStandardFixtures();
        final SolrQuery query = new SolrQuery();
        query.add("spatial", "{!sort=true}40.7142691, -74.0059729");
        getServer().query(query);
        query.addFilterQuery("rating:4.0");
        assertResultsInOrder(query, "New York", "Staten Island", "Yonkers");
    }

    @Test public void specifiedLimit() throws Exception {
        addStandardFixtures();
View Full Code Here

    }

    @Test public void searchWithoutSpatial() throws Exception {
        addStandardFixtures();
        final SolrQuery query = new SolrQuery();
        query.addFilterQuery("rating:4.0");
        assertResults(query, "New York", "Staten Island", "Yonkers");
    }

    private void addStandardFixtures() throws Exception {
        addStandardFixtures(STANDARD_LAT_FIELD, STANDARD_LNG_FIELD);
View Full Code Here

                .setRows(searchCriteria.getPageSize())
                .setStart((searchCriteria.getPage() - 1) * searchCriteria.getPageSize());
        if (filterQueries != null) {
            solrQuery.setFilterQueries(filterQueries);
        }
        solrQuery.addFilterQuery(shs.getNamespaceFieldName() + ":(\"" + shs.getCurrentNamespace() + "\")");
        solrQuery.set("defType", "edismax");
        solrQuery.set("qf", buildQueryFieldsString());

        // Attach additional restrictions
        attachSortClause(solrQuery, searchCriteria, defaultSort);
View Full Code Here

TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.