Package org.apache.lucene.index

Examples of org.apache.lucene.index.AtomicReaderContext.reader()


    dq.add(tq("dek", "DOES_NOT_EXIST"));
    assertTrue(s.getTopReaderContext() instanceof AtomicReaderContext);
    QueryUtils.check(random(), dq, s);
    final Weight dw = s.createNormalizedWeight(dq);
    AtomicReaderContext context = (AtomicReaderContext)s.getTopReaderContext();
    final Scorer ds = dw.scorer(context, true, false, context.reader().getLiveDocs());
    assertTrue("firsttime skipTo found no match",
        ds.advance(3) != DocIdSetIterator.NO_MORE_DOCS);
    assertEquals("found wrong docid", "d4", r.document(ds.docID()).get("id"));
  }
 
View Full Code Here


      }
      bi.setText(content);
      int doc = docids[i];
      int leaf = ReaderUtil.subIndex(doc, leaves);
      AtomicReaderContext subContext = leaves.get(leaf);
      AtomicReader r = subContext.reader();
      Terms t = r.terms(field);
      if (t == null) {
        continue; // nothing to do
      }
      if (leaf != lastLeaf) {
View Full Code Here

      TreeSet<Term> extractedTerms = new TreeSet<Term>();
      q.extractTerms(extractedTerms);
      for (Term term : extractedTerms) {
        termContexts.put(term, TermContext.build(context, term, true));
      }
      Bits acceptDocs = context.reader().getLiveDocs();
      final Spans spans = q.getSpans(context, acceptDocs, termContexts);

      // collect span positions
      while (spans.next()) {
        spanPositions.add(new PositionSpan(spans.start(), spans.end() - 1));
View Full Code Here

      termContexts.put(term, TermContext.build(topLevelReaderContext, term, true));
    }
    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);
  }

  @Override
View Full Code Here

    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;
      }
View Full Code Here

      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);
    }
View Full Code Here

      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 (current.skipTo(target - leaves.get(leafOrd).docBase)) {
        return true;
      }
View Full Code Here

      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

    AtomicReaderContext context = (AtomicReaderContext) reader.getContext();
    w.close();

    List<Term> terms = new ArrayList<Term>();
    terms.add(new Term(fieldName, "19"));
    FixedBitSet bits = (FixedBitSet) termsFilter(random().nextBoolean(), terms).getDocIdSet(context, context.reader().getLiveDocs());
    assertNull("Must match nothing", bits);

    terms.add(new Term(fieldName, "20"));
    bits = (FixedBitSet) termsFilter(random().nextBoolean(), terms).getDocIdSet(context, context.reader().getLiveDocs());
    assertEquals("Must match 1", 1, bits.cardinality());
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.