Package org.apache.lucene.search

Examples of org.apache.lucene.search.Filter


            }
          }
          key.setImpl( def.getImpl() );
        }

        Filter filter = def.isCache() ?
            searchFactoryImplementor.getFilterCachingStrategy().getCachedFilter( key ) :
            null;
        if (filter == null) {
          if ( def.getFactoryMethod() != null ) {
            try {
View Full Code Here


                  });
                }
               
                if (docsets.size()>0){
                  br.setFilter(
                    new Filter(){
                @Override
                public DocIdSet getDocIdSet(IndexReader reader)
                    throws IOException {
                  return new AndDocIdSet(docsets);
                }
View Full Code Here

  }
 
  private boolean isNoQueryNoFilter(BrowseRequest req)
  {
    Query q = req.getQuery();
    Filter filter = req.getFilter();
    return ((q == null || q instanceof MatchAllDocsQuery) && filter == null && !_reader.hasDeletions());
  }
View Full Code Here

    Set<String> fields = getFacetNames();

    LinkedList<Filter> preFilterList = new LinkedList<Filter>();
    List<FacetHitCollector> facetHitCollectorList = new LinkedList<FacetHitCollector>();
   
    Filter baseFilter = req.getFilter();
    if (baseFilter != null)
    {
      preFilterList.add(baseFilter);
    }

    int selCount = req.getSelectionCount();
    boolean isNoQueryNoFilter = isNoQueryNoFilter(req);

    boolean isDefaultSearch = isNoQueryNoFilter && selCount == 0;
    try
    {
     
      for (String name : fields)
      {
        BrowseSelection sel = req.getSelection(name);
        FacetSpec ospec = req.getFacetSpec(name);

        FacetHandler<?> handler = getFacetHandler(name);
       
        if (handler == null){
          logger.error("facet handler: "+name+" is not defined, ignored.");
          continue;
        }
       
        FacetHitCollector facetHitCollector = null;

        RandomAccessFilter filter = null;
        if (sel != null)
        {
          filter = handler.buildFilter(sel);
        }

        if (ospec == null)
        {
          if (filter != null)
          {
            preFilterList.add(filter);
          }
        }
        else
        {
          /*FacetSpec fspec = new FacetSpec(); // OrderValueAsc,
          fspec.setMaxCount(0);
          fspec.setMinHitCount(1);
         
          fspec.setExpandSelection(ospec.isExpandSelection());*/
          FacetSpec fspec = ospec;

          facetHitCollector = new FacetHitCollector();
          facetHitCollector.facetHandler = handler;
         
          if (isDefaultSearch)
          {
          facetHitCollector._collectAllSource=handler.getFacetCountCollectorSource(sel, fspec);
          }
          else
          {
            facetHitCollector._facetCountCollectorSource = handler.getFacetCountCollectorSource(sel, fspec);           
            if (ospec.isExpandSelection())
            {
              if (isNoQueryNoFilter && sel!=null && selCount == 1)
              {
              facetHitCollector._collectAllSource=handler.getFacetCountCollectorSource(sel, fspec);
                if (filter != null)
                {
                  preFilterList.add(filter);
                }
              }
              else
              {
                if (filter != null)
                {
                  facetHitCollector._filter = filter;
                }
              }
            }
            else
            {
              if (filter != null)
              {
                preFilterList.add(filter);
              }
            }
          }
        }
        if (facetHitCollector != null)
        {
          facetHitCollectorList.add(facetHitCollector);
        }
      }

      Filter finalFilter = null;
      if (preFilterList.size() > 0)
      {
        if (preFilterList.size() == 1)
        {
          finalFilter = preFilterList.getFirst();
View Full Code Here

                {
                    booleanQuery.add( parser.parse( previousSearchTerm ), BooleanClause.Occur.MUST );
                }

                query = new LuceneQuery( booleanQuery );
                Filter filter = new QueryWrapperFilter( parser.parse( term ) );
                results = searchAll( query, limits, indexes, filter );
            }
            results.getRepositories().addAll( this.localIndexedRepositories );

            return results;
View Full Code Here

    group = groups.groups[3];
    compareGroupValue(null, group);
    assertEquals(1, group.scoreDocs.length);
    assertEquals(6, group.scoreDocs[0].doc);

    Filter lastDocInBlock = new CachingWrapperFilter(new QueryWrapperFilter(new TermQuery(new Term("groupend", "x"))));
    groupingSearch = new GroupingSearch(lastDocInBlock);
    groups = groupingSearch.search(indexSearcher, null, new TermQuery(new Term("content", "random")), 0, 10);

    assertEquals(7, groups.totalHitCount);
    assertEquals(7, groups.totalGroupedHitCount);
View Full Code Here

    _allFacetHandlerMap = null;
  }

  private boolean isNoQueryNoFilter(BrowseRequest req) {
    Query q = req.getQuery();
    Filter filter = req.getFilter();
    return ((q == null || q instanceof MatchAllDocsQuery) && filter == null && !_reader
        .hasDeletions());
  }
View Full Code Here

    Set<String> fields = getFacetNames();

    LinkedList<Filter> preFilterList = new LinkedList<Filter>();
    List<FacetHitCollector> facetHitCollectorList = new LinkedList<FacetHitCollector>();

    Filter baseFilter = req.getFilter();
    if (baseFilter != null) {
      preFilterList.add(baseFilter);
    }

    int selCount = req.getSelectionCount();
    boolean isNoQueryNoFilter = isNoQueryNoFilter(req);

    boolean isDefaultSearch = isNoQueryNoFilter && selCount == 0;
    try {

      for (String name : fields) {
        BrowseSelection sel = req.getSelection(name);
        FacetSpec ospec = req.getFacetSpec(name);

        FacetHandler<?> handler = getFacetHandler(name);

        if (handler == null) {
          logger.error("facet handler: " + name + " is not defined, ignored.");
          continue;
        }

        FacetHitCollector facetHitCollector = null;

        RandomAccessFilter filter = null;
        if (sel != null) {
          filter = handler.buildFilter(sel);
        }

        if (ospec == null) {
          if (filter != null) {
            preFilterList.add(filter);
          }
        } else {
          FacetSpec fspec = ospec;

          facetHitCollector = new FacetHitCollector();
          facetHitCollector.facetHandler = handler;

          if (isDefaultSearch) {
            facetHitCollector._collectAllSource = handler.getFacetCountCollectorSource(sel, fspec);
          } else {
            facetHitCollector._facetCountCollectorSource = handler.getFacetCountCollectorSource(
              sel, fspec);
            if (ospec.isExpandSelection()) {
              if (isNoQueryNoFilter && sel != null && selCount == 1) {
                facetHitCollector._collectAllSource = handler.getFacetCountCollectorSource(sel,
                  fspec);
                if (filter != null) {
                  preFilterList.add(filter);
                }
              } else {
                if (filter != null) {
                  facetHitCollector._filter = filter;
                }
              }
            } else {
              if (filter != null) {
                preFilterList.add(filter);
              }
            }
          }
        }
        if (facetHitCollector != null) {
          facetHitCollectorList.add(facetHitCollector);
        }
      }

      Filter finalFilter = null;
      if (preFilterList.size() > 0) {
        if (preFilterList.size() == 1) {
          finalFilter = preFilterList.getFirst();
        } else {
          finalFilter = new AndFilter(preFilterList);
View Full Code Here

      return new CustomScoreQuery(strategy.makeQuery(args), new FunctionQuery(valueSource));
    } else {
      //strategy.makeQuery() could potentially score (isn't well defined) so instead we call
      // makeFilter() and wrap

      Filter filter = strategy.makeFilter(args);
      if (filter instanceof QueryWrapperFilter) {
        return ((QueryWrapperFilter)filter).getQuery();
      } else {
        return new ConstantScoreQuery(filter);
      }
View Full Code Here

      throws IOException {
    GeoRange range = GeoFacetCountCollector.parse(value);
    SpatialArgs spatialArgs = new SpatialArgs(SpatialOperation.Intersects,
        SpatialContext.GEO.makeCircle(range.getLon(), range.getLat(),
          DistanceUtils.dist2Degrees(range.getRad(), DistanceUtils.EARTH_MEAN_RADIUS_KM)));
    Filter filter = spatialStrategy.makeFilter(spatialArgs);
    if (filter == null) {
      return null;
    }
    return new SpatialFacetFilter(filter);
  }
View Full Code Here

TOP

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

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.