Package org.apache.lucene.search

Examples of org.apache.lucene.search.Filter


    }
    return filter;
  }

  private Filter createFilter(FilterDef def, Object instance) {
    Filter filter = null;
    if ( def.getFactoryMethod() != null ) {
      try {
        filter = (Filter) def.getFactoryMethod().invoke( instance );
      }
      catch (IllegalAccessException e) {
View Full Code Here


      CacheQuery cacheQuery = Search.getSearchManager(cache).getQuery(luceneQuery);
      List<Object> found = cacheQuery.list();

      assert found.size() == 2;

      Filter filter = new PrefixFilter(new Term("blurb", "cheese"));

      cacheQuery.filter(filter);

      found = cacheQuery.list();
View Full Code Here

  private void buildFilters() {
    ChainedFilter chainedFilter = null;
    if ( !filterDefinitions.isEmpty() ) {
      chainedFilter = new ChainedFilter();
      for ( FullTextFilterImpl fullTextFilter : filterDefinitions.values() ) {
        Filter filter = buildLuceneFilter( fullTextFilter );
        if ( filter != null ) {
          chainedFilter.addFilter( filter );
        }
      }
    }
View Full Code Here

    Object instance = createFilterInstance( fullTextFilter, def );
    FilterKey key = createFilterKey( def, instance );

    // try to get the filter out of the cache
    Filter filter = cacheInstance( def.getCacheMode() ) ?
        searchFactoryImplementor.getFilterCachingStrategy().getCachedFilter( key ) :
        null;

    if ( filter == null ) {
      filter = createFilter( def, instance );
View Full Code Here

  private boolean isPreQueryFilterOnly(FilterDef def) {
    return def.getImpl().equals( ShardSensitiveOnlyFilter.class );
  }

  private Filter createFilter(FilterDef def, Object instance) {
    Filter filter;
    if ( def.getFactoryMethod() != null ) {
      try {
        filter = ( Filter ) def.getFactoryMethod().invoke( instance );
      }
      catch ( IllegalAccessException e ) {
View Full Code Here

    // Test to see if child Element is a query or filter that needs to be
    // cached
    QueryBuilder qb = queryFactory.getQueryBuilder(childElement.getNodeName());
    Object cacheKey = null;
    Query q = null;
    Filter f = null;
    if (qb != null) {
      q = qb.getQuery(childElement);
      cacheKey = q;
    } else {
      f = filterFactory.getFilter(childElement);
      cacheKey = f;
    }
    Filter cachedFilter = filterCache.get(cacheKey);
    if (cachedFilter != null) {
      return cachedFilter; // cache hit
    }

    //cache miss
View Full Code Here

  }
 
  public void testQueries() throws Exception {
    int n = atLeast(4);
    for (int i = 0; i < n; i++) {
      Filter odd = new QueryWrapperFilter(new TermQuery(new Term("oddeven", "odd")));
      assertQuery(new MatchAllDocsQuery(), null);
      assertQuery(new TermQuery(new Term("english", "one")), null);
      assertQuery(new MatchAllDocsQuery(), odd);
      assertQuery(new TermQuery(new Term("english", "four")), odd);
      BooleanQuery bq = new BooleanQuery();
View Full Code Here

    writer.forceMerge(1);
    final DirectoryReader indexReader = writer.getReader();
    writer.close();

    final AtomicReader reader = getOnlySegmentReader(indexReader);
    final Filter parentsFilter = new FixedBitSetCachingWrapperFilter(new QueryWrapperFilter(new TermQuery(new Term("parent", "true"))));
    final FixedBitSet parentBits = (FixedBitSet) parentsFilter.getDocIdSet(reader.getContext(), null);

    final NumericDocValues parentValues = reader.getNumericDocValues("parent_val");
    final Sorter.DocComparator parentComparator = new Sorter.DocComparator() {
      @Override
      public int compare(int docID1, int docID2) {
View Full Code Here

    {
      //Search with circle
      //note: SpatialArgs can be parsed from a string
      SpatialArgs args = new SpatialArgs(SpatialOperation.Intersects,
          ctx.makeCircle(-80.0, 33.0, DistanceUtils.dist2Degrees(200, DistanceUtils.EARTH_MEAN_RADIUS_KM)));
      Filter filter = strategy.makeFilter(args);
      TopDocs docs = indexSearcher.search(new MatchAllDocsQuery(), filter, 10, idSort);
      assertDocMatchedIds(indexSearcher, docs, 2);
      //Now, lets get the distance for the 1st doc via computing from stored point value:
      // (this computation is usually not redundant)
      Document doc1 = indexSearcher.doc(docs.scoreDocs[0].doc);
View Full Code Here

    document.add(new StringField("fieldXXX", "x", Field.Store.NO));
    w.addDocument(document);

    IndexSearcher searcher = new IndexSearcher(DirectoryReader.open(w.w, false));
    w.close();
    Filter parentFilter = new QueryWrapperFilter(new TermQuery(new Term("__type", "parent")));
    Filter childFilter = new QueryWrapperFilter(new PrefixQuery(new Term("field2")));
    ToParentBlockJoinQuery query = new ToParentBlockJoinQuery(
        new FilteredQuery(new MatchAllDocsQuery(), childFilter),
        new FixedBitSetCachingWrapperFilter(parentFilter),
        ScoreMode.None
    );
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.