Package org.apache.lucene.index

Examples of org.apache.lucene.index.TermPositions.nextPosition()


      if (x == 1) {
        continue;
      }
      assertEquals(1, tp.nextPosition());
      assertEquals(3, tp.nextPosition());
      assertEquals(6, tp.nextPosition());

      // only one doc has "a"
      assertFalse(tp.next());

      IndexSearcher is = new IndexSearcher(r);
View Full Code Here


    IndexSearcher searcher = new IndexSearcher(store);
   
    TermPositions pos = searcher.getIndexReader().termPositions(new Term("field", "1"));
    pos.next();
    // first token should be at position 0
    assertEquals(0, pos.nextPosition());
   
    pos = searcher.getIndexReader().termPositions(new Term("field", "2"));
    pos.next();
    // second token should be at position 2
    assertEquals(2, pos.nextPosition());
View Full Code Here

    assertEquals(0, pos.nextPosition());
   
    pos = searcher.getIndexReader().termPositions(new Term("field", "2"));
    pos.next();
    // second token should be at position 2
    assertEquals(2, pos.nextPosition());
   
    PhraseQuery q;
    ScoreDoc[] hits;

    q = new PhraseQuery();
View Full Code Here

      if (x == 1) {
        expected = Integer.MAX_VALUE;
      } else {
        expected = 0;
      }
      assertEquals(expected, tp.nextPosition());
      if (x == 1) {
        continue;
      }
      assertEquals(1, tp.nextPosition());
      assertEquals(3, tp.nextPosition());
View Full Code Here

      }
      assertEquals(expected, tp.nextPosition());
      if (x == 1) {
        continue;
      }
      assertEquals(1, tp.nextPosition());
      assertEquals(3, tp.nextPosition());
      assertEquals(6, tp.nextPosition());

      // only one doc has "a"
      assertFalse(tp.next());
View Full Code Here

   
    IndexReader reader = IndexReader.open(dir);
    TermPositions termPositions = reader.termPositions(new Term("preanalyzed", "term1"));
    assertTrue(termPositions.next());
    assertEquals(1, termPositions.freq());
    assertEquals(0, termPositions.nextPosition());

    termPositions.seek(new Term("preanalyzed", "term2"));
    assertTrue(termPositions.next());
    assertEquals(2, termPositions.freq());
    assertEquals(1, termPositions.nextPosition());
View Full Code Here

    assertEquals(0, termPositions.nextPosition());

    termPositions.seek(new Term("preanalyzed", "term2"));
    assertTrue(termPositions.next());
    assertEquals(2, termPositions.freq());
    assertEquals(1, termPositions.nextPosition());
    assertEquals(3, termPositions.nextPosition());
   
    termPositions.seek(new Term("preanalyzed", "term3"));
    assertTrue(termPositions.next());
    assertEquals(1, termPositions.freq());
View Full Code Here

    termPositions.seek(new Term("preanalyzed", "term2"));
    assertTrue(termPositions.next());
    assertEquals(2, termPositions.freq());
    assertEquals(1, termPositions.nextPosition());
    assertEquals(3, termPositions.nextPosition());
   
    termPositions.seek(new Term("preanalyzed", "term3"));
    assertTrue(termPositions.next());
    assertEquals(1, termPositions.freq());
    assertEquals(2, termPositions.nextPosition());
View Full Code Here

    assertEquals(3, termPositions.nextPosition());
   
    termPositions.seek(new Term("preanalyzed", "term3"));
    assertTrue(termPositions.next());
    assertEquals(1, termPositions.freq());
    assertEquals(2, termPositions.nextPosition());
    reader.close();
   
    // 3) reset stream and consume tokens again
    stream.reset();
    checkTokens(stream);
View Full Code Here

    // Make sure position is still incremented when
    // massive term is skipped:
    TermPositions tps = reader.termPositions(new Term("content", "another"));
    assertTrue(tps.next());
    assertEquals(1, tps.freq());
    assertEquals(3, tps.nextPosition());

    // Make sure the doc that has the massive term is in
    // the index:
    assertEquals("document with wicked long term should is not in the index!", 2, reader.numDocs());
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.