/** * Search one index. This is used if no projects are set up. * @param paging whether to use paging (if yes, first X pages will load * faster) * @param root which db to search * @throws IOException */ private void searchSingleDatabase(File root, boolean paging) throws IOException { IndexReader ireader = DirectoryReader.open(FSDirectory.open(root.toPath())); searcher = new IndexSearcher(ireader); collector = TopScoreDocCollector.create(hitsPerPage * cachePages); searcher.search(query, collector); totalHits = collector.getTotalHits(); if (!paging && totalHits > 0) { collector = TopScoreDocCollector.create(totalHits); searcher.search(query, collector); } hits = collector.topDocs().scoreDocs; for (ScoreDoc hit : hits) { int docId = hit.doc; Document d = searcher.doc(docId); docs.add(d); } }
collector = TopScoreDocCollector.create(hitsPerPage * cachePages); searcher.search(query, collector); totalHits = collector.getTotalHits(); if (!paging && totalHits > 0) { collector = TopScoreDocCollector.create(totalHits);
@Override public int getTotalHits() { return tdc.getTotalHits(); }
@Override public int getTotalHits() { return tdc.getTotalHits(); }
TopScoreDocCollector collector = TopScoreDocCollector.create(10, true); searcher.search(query, collector); TopDocs topDocs = collector.topDocs(); int numResults = collector.getTotalHits();
if ( topHitCount < hits.getTotalHits() ) topHitCount = hits.getTotalHits();
if ( topHitCount < hits.getTotalHits() ) topHitCount = hits.getTotalHits();
if ( topHitCount < hits.getTotalHits() ) topHitCount = hits.getTotalHits();
if ( collector.getTotalHits() == 0 ) if ( collector.getTotalHits() > 1 )
if ( collector.getTotalHits() == 0 ) if ( collector.getTotalHits() > 1 )
topCollector = TopScoreDocCollector.create(maxHits, true); is.search(query, filter, topCollector); } while (topCollector.getTotalHits() >= maxHits);
if ( collector.getTotalHits() > 0 ) for ( int i = 0; i < collector.getTotalHits(); i++ )
if ( collector.getTotalHits() > 0 ) for ( int i = 0; i < collector.getTotalHits(); i++ )
if ( collector.getTotalHits() == 0 ) hitCount += collector.getTotalHits();
if ( collector.getTotalHits() == 0 ) hitCount += collector.getTotalHits();
if ( collector.getTotalHits() > 0 ) hitCount += collector.getTotalHits();
if ( collector.getTotalHits() > 0 ) hitCount += collector.getTotalHits();
return new IteratorSearchResponse( request.getQuery(), hits.getTotalHits(), new DefaultIteratorResultSet( request, indexSearcher, contexts, hits.topDocs() ) );
return new IteratorSearchResponse( request.getQuery(), hits.getTotalHits(), new DefaultIteratorResultSet( request, indexSearcher, contexts, hits.topDocs() ) );
return new IteratorSearchResponse( request.getQuery(), hits.getTotalHits(), new DefaultIteratorResultSet( request, indexSearcher, contexts, hits.topDocs() ) );