Examples of topDocs()


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

          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

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

    private void getHits() throws IOException {
        TopFieldDocCollector collector = new TopFieldDocCollector(reader, sort, numHits);
        searcher.search(query, collector);
        this.size = collector.getTotalHits();
        ScoreDoc[] docs = collector.topDocs().scoreDocs;
        for (int i = scoreNodes.size(); i < docs.length; i++) {
            String uuid = reader.document(docs[i].doc).get(FieldNames.UUID);
            NodeId id = new NodeId(UUID.fromString(uuid));
            scoreNodes.add(new ScoreNode(id, docs[i].score, docs[i].doc));
        }
View Full Code Here

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

    }

    try {
      TopScoreDocCollector collector = TopScoreDocCollector.create(20, false);
      mIndexSearcher.search(query, collector);
      return collector.topDocs().scoreDocs;

    } catch (IOException exc) {
      throw new RegainException("Searching query failed", exc);
    }
  }
View Full Code Here

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

      Document doc;
      try {
        setIndexMode(SEARCHING_MODE);
        TopScoreDocCollector collector = TopScoreDocCollector.create(20, false);
        mIndexSearcher.search(query, collector);
        ScoreDoc[] hits = collector.topDocs().scoreDocs;

        if (hits.length > 0) {
          if (hits.length > 1) {
            for (int i = 1; i < hits.length; i++) {
              markForDeletion(mIndexSearcher.doc(hits[i].doc));
View Full Code Here

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

    TopScoreDocCollector docCollector = TopScoreDocCollector.create(100, true);
    QueryParser queryParser = new QueryParser(Version.LUCENE_43, "text", new StandardAnalyzer(
        Version.LUCENE_43));
    Query query = queryParser.parse("Foo*");
    searcher.search(query, docCollector);
    TopDocs docs = docCollector.topDocs();
    ScoreDoc[] scoreDocs = docs.scoreDocs;

    assertEquals("should be doc 0", 0, scoreDocs[0].doc);
    assertEquals("should be doc 1", 1, scoreDocs[1].doc);
    assertEquals("should be doc 2", 2, scoreDocs[2].doc);
View Full Code Here

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

        QueryParser parser = new QueryParser(luceneVersion, "contents", analyzer);
        Query query = parser.parse(searchPhrase);
        TopScoreDocCollector collector = TopScoreDocCollector.create(maxNumberOfHits, true);
        indexSearcher.search(query, collector);
        hits = collector.topDocs().scoreDocs;
       
        LOG.trace("*** Search generated {} hits ***", hits.length);
        return hits.length;
    }
}
View Full Code Here

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

        // Collect enough docs to show 5 pages
        TopScoreDocCollector collector = TopScoreDocCollector.create(
                5 * hitsPerPage, false);
        searcher.search(query, collector);
        ScoreDoc[] hits = collector.topDocs().scoreDocs;

        int numTotalHits = collector.getTotalHits();
        outMultiData.add(numTotalHits + " total matching documents");

        int start = 0;
View Full Code Here

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

        if (_runSlow) {
          col = new SlowCollector(col);
        }
        searcher.search(query, col);
        totalHitsRef.totalHits.set(collector.getTotalHits());
        TopDocs topDocs = collector.topDocs();
        scoreDocs = topDocs.scoreDocs;
      } catch (StopExecutionCollectorException e) {
        throw new BlurException(STOP_EXECUTION_COLLECTOR_EXCEPTION, null, ErrorType.UNKNOWN);
      } catch (ExitingReaderException e) {
        throw new BlurException(STOP_EXECUTION_COLLECTOR_EXCEPTION, null, ErrorType.UNKNOWN);
View Full Code Here

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

                    return;
                }
                else
                {
                    // good, we have one descriptor as should
                    Document descriptor = indexSearcher.doc( collector.topDocs().scoreDocs[0].doc );
                    String[] h = StringUtils.split( descriptor.get( FLD_IDXINFO ), ArtifactInfo.FS );
                    // String version = h[0];
                    String repoId = h[1];

                    // // compare version
View Full Code Here

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

        final TopScoreDocCollector collector = TopScoreDocCollector.create( 1, false );
        final IndexSearcher indexSearcher = acquireIndexSearcher();
        try
        {
            indexSearcher.search( new TermQuery( new Term( field, filedValue ) ), collector );
            TopDocs topDocs = collector.topDocs();
            Set<String> groups = new LinkedHashSet<String>( Math.max( 10, topDocs.totalHits ) );
            if ( topDocs.totalHits > 0 )
            {
                Document doc = indexSearcher.doc( topDocs.scoreDocs[0].doc );
                String groupList = doc.get( listField );
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.