Package org.apache.lucene.search

Examples of org.apache.lucene.search.QueryFilter


    //query
    Query query = new TermQuery(new Term("field", "sample"));
   
    //filter
    TermQuery filterQuery = new TermQuery(new Term("filter", "another"));
    Filter filter = new QueryFilter(filterQuery);
   
    //document
    Document document = new Document();
    document.add(new Field("field", "a sample", Field.Store.YES, Field.Index.TOKENIZED));
    document.add(new Field("filter", "a sample filter", Field.Store.YES, Field.Index.TOKENIZED));
View Full Code Here


    //query
    Query query = new TermQuery(new Term("field", "sample"));
   
    //filter
    TermQuery filterQuery = new TermQuery(new Term("filter", "another"));
    Filter filter = new QueryFilter(filterQuery);
   
    //document
    Document document = new Document();
    document.add(new Field("field", "a sample", Field.Store.YES, Field.Index.TOKENIZED));
    document.add(new Field("filter", "a sample filter", Field.Store.YES, Field.Index.TOKENIZED));
View Full Code Here

    //query
    Query query = new TermQuery(new Term("field", "sample"));
   
    //filter
    TermQuery filterQuery = new TermQuery(new Term("filter", "another"));
    Filter filter = new QueryFilter(filterQuery);

    //sort
    Sort sort = new Sort("sort");
   
    //document
View Full Code Here

    //query
    Query query = new TermQuery(new Term("field", "sample"));
   
    //filter
    TermQuery filterQuery = new TermQuery(new Term("filter", "another"));
    Filter filter = new QueryFilter(filterQuery);

    //sort
    Sort sort = new Sort("sort");
   
    //document
View Full Code Here

        filter = (Filter)cache.get(cacheQuery);
      }
      if (filter == null) {                       // miss

        if (filterQuery.getClauses().length != 0) // add filterQuery to filters
          filters.add(new QueryFilter(filterQuery));

        if (filters.size() == 1) {                // convert filters to filter
          filter = (Filter)filters.get(0);
        } else {
          filter = new ChainedFilter((Filter[])filters.toArray
View Full Code Here

        filter = (Filter)cache.get(cacheQuery);
      }
      if (filter == null) {                       // miss

        if (filterQuery.getClauses().length != 0) // add filterQuery to filters
          filters.add(new QueryFilter(filterQuery));

        if (filters.size() == 1) {                // convert filters to filter
          filter = (Filter)filters.get(0);
        } else {
          filter = new ChainedFilter((Filter[])filters.toArray
View Full Code Here

    if (filterQuery != null) {
      synchronized (cache) {                      // check cache
        filter = (Filter)cache.get(filterQuery);
      }
      if (filter == null) {                       // miss
        filter = new QueryFilter(filterQuery);    // construct new entry
        synchronized (cache) {
          cache.put(filterQuery, filter);         // cache it
        }
      }       
    }
View Full Code Here

            throw new IllegalStateException("Searcher is closed");
        if (query == null)
            throw new RuntimeException("query is null can not apply search");
        if (feedId == null)
            throw new IllegalArgumentException("feed id must not be null");
        QueryFilter filter = null;
        synchronized (queryFilterCache) {
            filter = queryFilterCache.get(feedId);
       
        if (filter == null)
            filter = new QueryFilter(new TermQuery(new Term(
                    IndexDocument.FIELD_FEED_ID, feedId)));
            queryFilterCache.put(feedId, filter);
        }
        IndexSearcher indexSearcher = this.searcher.get();
        Hits hits = indexSearcher.search(query, filter);
View Full Code Here

    long start = System.currentTimeMillis();
    long startQuery = System.currentTimeMillis();

    Filter filter;
    if (uak == null) {
      filter = new QueryFilter(queryParser.parse(
          "accesorid:public"
      ));
      LOGGER.debug("filtering query with accesorid:public");
    } else {
      StringBuffer f = new StringBuffer("accesorid:public OR accesorid:").append(uak.getUserId());
      for (Iterator iter = uak.getGroups().iterator(); iter.hasNext();) {
        Long gid = (Long) iter.next();
        f.append(" OR accesorid:").append(gid);
      }
      filter = new QueryFilter(queryParser.parse(
          f.toString()
      ));
      LOGGER.debug("filtering query with "+f);
    }
   
    Hits hits = is.search(query, filter);
    long endQuery = System.currentTimeMillis();
   
        int hitsCount = hits.length();
        long queryProcessTime = endQuery - startQuery;
       
        Map h = new LinkedHashMap();
        List results = new ArrayList(RESULTS_PER_PAGE);
       
        // first we only look for the accurate hits
        int i;
        int countModuleHit = 0;
        for (i = 0; i < hits.length() && results.size() < RESULTS_PER_PAGE; i++) {
          Document doc = hits.doc(i);
          String key = doc.get("visibility")+"/"+doc.get("organisation")+"/"+doc.get("module")+"/"+doc.get("fqcn");
          Hit hit = (Hit) h.get(key);
          if (hit == null) {
            hit = new Hit(doc.get("visibility"), doc.get("organisation"), doc.get("module"), doc.get("fqcn"), hits.score(i));
            h.put(key, hit);
            if (countModuleHit >= startIndex) {
              results.add(hit);
            }
            countModuleHit++;
          }
          // not stricly necessary, but sometimes lucene doesn't find the revisions in the second step...
          hit.addRevision(doc.get("path"), doc.get("revision"));
        }
        Long nextResults =  i == hits.length()?null:new Long(startIndex+RESULTS_PER_PAGE);
        Long previousResults = startIndex == 0?null:new Long(startIndex-RESULTS_PER_PAGE);
       
        // then we fill in revisions
        for (Iterator iter = results.iterator(); iter.hasNext();) {
      Hit hit = (Hit) iter.next();
      hits = is.search(query, new QueryFilter(queryParser.parse(
          "organisation:"+hit.getOrganisation()
          +" AND module:"+hit.getModule()
          +" AND fqcn:"+hit.getClassname()
      )));
      for (i = 0; i < hits.length(); i++) {
View Full Code Here

    // date filter matches everything too
    Date pastTheEnd = parseDate("2099 Jan 1");
    dateFilter = DateFilter.Before("date", pastTheEnd);

    bobFilter = new QueryFilter(
        new TermQuery(new Term("owner", "bob")));
    sueFilter = new QueryFilter(
        new TermQuery(new Term("owner", "sue")));
  }
View Full Code Here

TOP

Related Classes of org.apache.lucene.search.QueryFilter

Copyright © 2018 www.massapicom. 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.