Package org.apache.lucene.index

Examples of org.apache.lucene.index.AtomicReaderContext


    testRange(2);
  }
 
  @Test
  public void testInverseRange() throws Exception {
    AtomicReaderContext context = SlowCompositeReaderWrapper.wrap(searcher.getIndexReader()).getContext();
    NumericRangeFilter<Long> f = NumericRangeFilter.newLongRange("field8", 8, 1000L, -1000L, true, true);
    assertNull("A inverse range should return the null instance",
        f.getDocIdSet(context, context.reader().getLiveDocs()));
    f = NumericRangeFilter.newLongRange("field8", 8, Long.MAX_VALUE, null, false, false);
    assertNull("A exclusive range starting with Long.MAX_VALUE should return the null instance",
               f.getDocIdSet(context, context.reader().getLiveDocs()));
    f = NumericRangeFilter.newLongRange("field8", 8, null, Long.MIN_VALUE, false, false);
    assertNull("A exclusive range ending with Long.MIN_VALUE should return the null instance",
               f.getDocIdSet(context, context.reader().getLiveDocs()));
  }
View Full Code Here


    Term allTerm = new Term(FIELD, "all");
    TermQuery termQuery = new TermQuery(allTerm);
   
    Weight weight = indexSearcher.createNormalizedWeight(termQuery);
    assertTrue(indexSearcher.getTopReaderContext() instanceof AtomicReaderContext);
    AtomicReaderContext context = (AtomicReaderContext)indexSearcher.getTopReaderContext();
    Scorer ts = weight.scorer(context, true, true, context.reader().getLiveDocs());
    // we have 2 documents with the term all in them, one document for all the
    // other values
    final List<TestHit> docs = new ArrayList<TestHit>();
    // must call next first
   
View Full Code Here

    Term allTerm = new Term(FIELD, "all");
    TermQuery termQuery = new TermQuery(allTerm);
   
    Weight weight = indexSearcher.createNormalizedWeight(termQuery);
    assertTrue(indexSearcher.getTopReaderContext() instanceof AtomicReaderContext);
    AtomicReaderContext context = (AtomicReaderContext) indexSearcher.getTopReaderContext();
    Scorer ts = weight.scorer(context, true, false, context.reader().getLiveDocs());
    assertTrue("next did not return a doc",
        ts.nextDoc() != DocIdSetIterator.NO_MORE_DOCS);
    assertTrue("score is not correct", ts.score() == 1.6931472f);
    assertTrue("next did not return a doc",
        ts.nextDoc() != DocIdSetIterator.NO_MORE_DOCS);
View Full Code Here

    Term allTerm = new Term(FIELD, "all");
    TermQuery termQuery = new TermQuery(allTerm);
   
    Weight weight = indexSearcher.createNormalizedWeight(termQuery);
    assertTrue(indexSearcher.getTopReaderContext() instanceof AtomicReaderContext);
    AtomicReaderContext context = (AtomicReaderContext) indexSearcher.getTopReaderContext();
    Scorer ts = weight.scorer(context, true, false, context.reader().getLiveDocs());
    assertTrue("Didn't skip", ts.advance(3) != DocIdSetIterator.NO_MORE_DOCS);
    // The next doc should be doc 5
    assertTrue("doc should be number 5", ts.docID() == 5);
  }
View Full Code Here

    for (Term term : terms) {
      termContexts.put(term, TermContext.build(topLevelReaderContext, term));
    }
    final List<AtomicReaderContext> leaves = topLevelReaderContext.leaves();
    if(leaves.size() == 1) {
      final AtomicReaderContext ctx = leaves.get(0);
      return query.getSpans(ctx, ctx.reader().getLiveDocs(), termContexts);
    }
    return new MultiSpansWrapper(leaves, query, termContexts);
  }
View Full Code Here

  public boolean next() throws IOException {
    if (leafOrd >= numLeaves) {
      return false;
    }
    if (current == null) {
      final AtomicReaderContext ctx = leaves.get(leafOrd);
      current = query.getSpans(ctx, ctx.reader().getLiveDocs(), termContexts);
    }
    while(true) {
      if (current.next()) {
        return true;
      }
      if (++leafOrd < numLeaves) {
        final AtomicReaderContext ctx = leaves.get(leafOrd);
        current = query.getSpans(ctx, ctx.reader().getLiveDocs(), termContexts);
      } else {
        current = null;
        break;
      }
    }
View Full Code Here

    }

    int subIndex = ReaderUtil.subIndex(target, leaves);
    assert subIndex >= leafOrd;
    if (subIndex != leafOrd) {
      final AtomicReaderContext ctx = leaves.get(subIndex);
      current = query.getSpans(ctx, ctx.reader().getLiveDocs(), termContexts);
      leafOrd = subIndex;
    } else if (current == null) {
      final AtomicReaderContext ctx = leaves.get(leafOrd);
      current = query.getSpans(ctx, ctx.reader().getLiveDocs(), termContexts);
    }
    while (true) {
      if (target < leaves.get(leafOrd).docBase) {
        // target was in the previous slice
        if (current.next()) {
          return true;
        }
      } else if (current.skipTo(target - leaves.get(leafOrd).docBase)) {
        return true;
      }
      if (++leafOrd < numLeaves) {
        final AtomicReaderContext ctx = leaves.get(leafOrd);
        current = query.getSpans(ctx, ctx.reader().getLiveDocs(), termContexts);
      } else {
        current = null;
        break;
      }
    }
View Full Code Here

    int slop = 1;
    IndexReaderContext topReaderContext = searcher.getTopReaderContext();
    List<AtomicReaderContext> leaves = topReaderContext.leaves();
    int subIndex = ReaderUtil.subIndex(11, leaves);
    for (int i = 0, c = leaves.size(); i < c; i++) {
      final AtomicReaderContext ctx = leaves.get(i);
    
      final Similarity sim = new DefaultSimilarity() {
        @Override
        public float sloppyFreq(int distance) {
          return 0.0f;
        }
      };
 
      final Similarity oldSim = searcher.getSimilarity();
      Scorer spanScorer;
      try {
        searcher.setSimilarity(sim);
        SpanNearQuery snq = new SpanNearQuery(
                                new SpanQuery[] {
                                  makeSpanTermQuery("t1"),
                                  makeSpanTermQuery("t2") },
                                slop,
                                ordered);
 
        spanScorer = searcher.createNormalizedWeight(snq).scorer(ctx, true, false, ctx.reader().getLiveDocs());
      } finally {
        searcher.setSimilarity(oldSim);
      }
      if (i == subIndex) {
        assertTrue("first doc", spanScorer.nextDoc() != DocIdSetIterator.NO_MORE_DOCS);
View Full Code Here

      final int size = compCTX.leaves().size();
      subSearchers = new ShardSearcher[size];
      docStarts = new int[size];
      int docBase = 0;
      for(int searcherIDX=0;searcherIDX<subSearchers.length;searcherIDX++) {
        final AtomicReaderContext leave = compCTX.leaves().get(searcherIDX);
        subSearchers[searcherIDX] = new ShardSearcher(leave, compCTX);
        docStarts[searcherIDX] = docBase;
        docBase += leave.reader().maxDoc();
      }
    }

    final List<SortField> sortFields = new ArrayList<SortField>();
    sortFields.add(new SortField("string", SortField.Type.STRING, true));
View Full Code Here

   */
  public void testSpanNearScorerSkipTo1() throws Exception {
    SpanNearQuery q = makeQuery();
    Weight w = searcher.createNormalizedWeight(q);
    IndexReaderContext topReaderContext = searcher.getTopReaderContext();
    AtomicReaderContext leave = topReaderContext.leaves().get(0);
    Scorer s = w.scorer(leave, true, false, leave.reader().getLiveDocs());
    assertEquals(1, s.advance(1));
  }
View Full Code Here

TOP

Related Classes of org.apache.lucene.index.AtomicReaderContext

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.