Package org.apache.lucene.search

Examples of org.apache.lucene.search.TopDocs


    final Query dq = twq(1)
    .with(child(must(nmqLong("ascfield8", 8, 1000L, 1000L, true, true)
    .setRewriteMethod(MultiNodeTermQuery.CONSTANT_SCORE_BOOLEAN_QUERY_REWRITE)
    .bound(2, 2)))).getLuceneProxyQuery();

    final TopDocs topDocs = index.searcher.search(dq, noDocs);
    final ScoreDoc[] sd = topDocs.scoreDocs;
    assertNotNull(sd);
    assertEquals("Score doc count", 1, sd.length );
  }
View Full Code Here


    Query dq = twq(1)
    .with(child(must(nmqLong(field, precisionStep, null, upper, true, true)
      .bound(2, 2)))).getLuceneProxyQuery();

    TopDocs topDocs = index.searcher.search(dq, null, noDocs, Sort.INDEXORDER);
    ScoreDoc[] sd = topDocs.scoreDocs;
    assertNotNull(sd);
    assertEquals("Score doc count", count, sd.length );
    Document doc=index.searcher.doc(sd[0].doc);
    assertEquals("First doc", startOffset, Long.parseLong(getLiteralValue(doc.get(field))));
View Full Code Here

    Query dq = twq(1)
    .with(child(must(nmqLong(field, precisionStep, lower, null, true, true)
      .bound(2, 2)))).getLuceneProxyQuery();

    TopDocs topDocs = index.searcher.search(dq, null, noDocs, Sort.INDEXORDER);
    ScoreDoc[] sd = topDocs.scoreDocs;
    assertNotNull(sd);
    assertEquals("Score doc count", noDocs-count, sd.length );
    Document doc=index.searcher.doc(sd[0].doc);
    assertEquals("First doc", count*distance+startOffset, Long.parseLong(getLiteralValue(doc.get(field))));
View Full Code Here

    index.searcher = newSearcher(index.reader);

    Query q = twq(1)
    .with(child(must(nmqLong("field4", NumericUtils.PRECISION_STEP_DEFAULT, null, null, true, true)
      .bound(2, 2)))).getLuceneProxyQuery();
    TopDocs topDocs = index.searcher.search(q, 10);
    assertEquals("Score doc count", 3,  topDocs.scoreDocs.length );

    q = twq(1)
    .with(child(must(nmqLong("field4", NumericUtils.PRECISION_STEP_DEFAULT, null, null, false, false)
      .bound(2, 2)))).getLuceneProxyQuery();
View Full Code Here

      upperBytes.append(uBytes);

      // test inclusive range
      MultiNodeTermQuery tq = (MultiNodeTermQuery) nmqLong(field, precisionStep, lower, upper, true, true).getNodeQuery();
      MultiNodeTermQuery cq = new NodeTermRangeQuery(field, lowerBytes, upperBytes, true, true);
      TopDocs tTopDocs = index.searcher.search(dq(tq), 1);
      TopDocs cTopDocs = index.searcher.search(dq(cq), 1);
      assertEquals("Returned count for NumericRangeQuery and TermRangeQuery must be equal", cTopDocs.totalHits, tTopDocs.totalHits );
      totalTermCountT += termCountT = this.countTerms(tq);
      totalTermCountC += termCountC = this.countTerms(cq);
      this.checkTermCounts(precisionStep, termCountT, termCountC);
      // test exclusive range
View Full Code Here

      }
      // test inclusive range
      Query tq = twq(1)
      .with(child(must(nmqLong(field, precisionStep, lower, upper, true, true)
        .bound(2, 2)))).getLuceneProxyQuery();
      TopDocs tTopDocs = index.searcher.search(tq, 1);
      assertEquals("Returned count of range query must be equal to inclusive range length", upper-lower+1, tTopDocs.totalHits );
      // test exclusive range
      tq=twq(1)
      .with(child(must(nmqLong(field, precisionStep, lower, upper, false, false)
        .bound(2, 2)))).getLuceneProxyQuery();
View Full Code Here

     */

    final Query dq = twq(1)
    .with(child(must(nmqDouble(field, precisionStep, lower, upper, true, true)
      .bound(2, 2)))).getLuceneProxyQuery();
    final TopDocs tTopDocs = index.searcher.search(dq, 1);
    assertEquals("Returned count of range query must be equal to inclusive range length", upper-lower+1, tTopDocs.totalHits, 0);
  }
View Full Code Here

    final IndexReader ir2 = writer2.getReader();

    final MultiReader mr = new MultiReader(ir1, ir2);
    final IndexSearcher searcher = newSearcher(mr);
    final FuzzyQuery fq = new FuzzyQuery(new Term(DEFAULT_TEST_FIELD, "z123456"), 1, 0, 2, false);
    final TopDocs docs = searcher.search(fq, 2);
    assertEquals(5, docs.totalHits); // 5 docs, from the a and b's

    mr.close();
    ir2.close();
    writer2.close();
View Full Code Here

    final Query dq = twq(1)
    .with(child(must(nmqInt(field, precisionStep, lower, upper, true, true)
    .setRewriteMethod(MultiNodeTermQuery.CONSTANT_SCORE_BOOLEAN_QUERY_REWRITE)
    .bound(2, 2)))).getLuceneProxyQuery();

    TopDocs topDocs;
    String type;

    type = " (constant score boolean rewrite)";
    topDocs = index.searcher.search(dq, null, noDocs, Sort.INDEXORDER);
View Full Code Here

    Query dq = twq(1)
    .with(child(must(nmqInt("field8", 8, 1000, -1000, true, true)
    .setRewriteMethod(MultiNodeTermQuery.CONSTANT_SCORE_BOOLEAN_QUERY_REWRITE))))
    .getLuceneProxyQuery();

    TopDocs topDocs = index.searcher.search(dq, null, noDocs, Sort.INDEXORDER);
    assertEquals("A inverse range should return the EMPTY_DOCIDSET instance", 0, topDocs.totalHits);

    dq = twq(1)
    .with(child(must(nmqInt("field8", 8, Integer.MAX_VALUE, null, false, false)
    .setRewriteMethod(MultiNodeTermQuery.CONSTANT_SCORE_BOOLEAN_QUERY_REWRITE))))
View Full Code Here

TOP

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

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.