Package org.apache.lucene.search

Examples of org.apache.lucene.search.TopFieldCollector.topDocs()


          super.setNextReader(context);
          assertFalse("segment should not be recognized as sorted as different sorter was used", segmentSorted);
        }
      });
      assertTrue(collector1.getTotalHits() >= collector2.getTotalHits());
      assertTopDocsEquals(collector1.topDocs().scoreDocs, collector2.topDocs().scoreDocs);
    }
    closeIndex();
  }

  private static void assertTopDocsEquals(ScoreDoc[] scoreDocs1, ScoreDoc[] scoreDocs2) {
View Full Code Here


    List<LookupResult> results = null;
    try {
      //System.out.println("got searcher=" + searcher);
      searcher.search(finalQuery, c2);

      TopFieldDocs hits = (TopFieldDocs) c.topDocs();

      // Slower way if postings are not pre-sorted by weight:
      // hits = searcher.search(query, null, num, SORT);
      results = createResults(searcher, hits, num, key, doHighlight, matchedTokens, prefixToken);
    } finally {
View Full Code Here

    private void getHits() throws IOException {
        TopFieldCollector collector = TopFieldCollector.create(sort, numHits, false, true, false, false);
        searcher.search(query, collector);
        size = collector.getTotalHits();
        offset += scoreDocs.length;
        scoreDocs = collector.topDocs(offset, numHits).scoreDocs;
        log.debug("getHits() {}/{}", scoreDocs.length, numHits);
        // double hits for next round
        numHits *= 2;
    }
}
View Full Code Here

                                                                      true,
                                                                      doDocScores,
                                                                      doMaxScore,
                                                                      true);
      DrillSidewaysResult r = search(query, hitCollector, fsp);
      return new DrillSidewaysResult(r.facetResults, hitCollector.topDocs());
    } else {
      return search(after, query, topN, fsp);
    }
  }
View Full Code Here

          TopFieldCollector collector = TopFieldCollector.create(
              sort, offset + limit, false, false, false, true);
          // TODO Investigate use of searchAfter
          searcher.search(convertToQuery(restrictions), collector);
          List<LogEntry> result = new LinkedList<LogEntry>();
          collectHits(searcher, collector.topDocs(offset), log.getDialect(), result);
          return new ResultPage(result, offset, collector.getTotalHits());
        } catch (IOException e) {
          // Unexpected exception; wrap with CoreException
          throw new CoreException(new Status(IStatus.ERROR, IndexPlugin.PLUGIN_ID,
              NLS.bind(Messages.LuceneIndexService_error_failedToReadIndex,
View Full Code Here

                                                                      true,
                                                                      doDocScores,
                                                                      doMaxScore,
                                                                      true);
      DrillSidewaysResult r = search(query, hitCollector, fsp);
      r.hits = hitCollector.topDocs();
      return r;
    } else {
      return search(after, query, topN, fsp);
    }
  }
View Full Code Here

                                                                      true,
                                                                      doDocScores,
                                                                      doMaxScore,
                                                                      true);
      DrillSidewaysResult r = search(query, hitCollector);
      return new DrillSidewaysResult(r.facets, hitCollector.topDocs());
    } else {
      return search(after, query, topN);
    }
  }
View Full Code Here

      final TermQuery query = new TermQuery(new Term("s", RandomPicks.randomFrom(random(), terms)));
      searcher.search(query, collector1);
      searcher.search(query, new EarlyTerminatingSortingCollector(collector2, sort, numHits));
    }
    assertTrue(collector1.getTotalHits() >= collector2.getTotalHits());
    assertTopDocsEquals(collector1.topDocs().scoreDocs, collector2.topDocs().scoreDocs);
  }
 
  public void testEarlyTerminationDifferentSorter() throws IOException {
    // test that the collector works correctly when the index was sorted by a
    // different sorter than the one specified in the ctor.
View Full Code Here

          assertFalse("segment should not be recognized as sorted as different sorter was used", segmentSorted);
        }
      });
    }
    assertTrue(collector1.getTotalHits() >= collector2.getTotalHits());
    assertTopDocsEquals(collector1.topDocs().scoreDocs, collector2.topDocs().scoreDocs);
  }

  private static void assertTopDocsEquals(ScoreDoc[] scoreDocs1, ScoreDoc[] scoreDocs2) {
    assertEquals(scoreDocs1.length, scoreDocs2.length);
    for (int i = 0; i < scoreDocs1.length; ++i) {
View Full Code Here

          // TODO: change the following to create TFC with in/out-of order
          // according to whether the query's Scorer.
          TopFieldCollector collector = TopFieldCollector.create(sort, numHits,
              true, withScore(), withMaxScore(), false);
          searcher.search(q, collector);
          hits = collector.topDocs();
        } else {
          hits = searcher.search(q, numHits);
        }
        //System.out.println("q=" + q + ":" + hits.totalHits + " total hits");
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.