@@ -188,19 +188,7 @@ public boolean isValidQuery() {
188
188
private void searchSingleDatabase (File root , boolean paging ) throws IOException {
189
189
IndexReader ireader = DirectoryReader .open (FSDirectory .open (root .toPath ()));
190
190
searcher = new IndexSearcher (ireader );
191
- collector = TopScoreDocCollector .create (hitsPerPage * cachePages );
192
- searcher .search (query , collector );
193
- totalHits = collector .getTotalHits ();
194
- if (!paging && totalHits > 0 ) {
195
- collector = TopScoreDocCollector .create (totalHits );
196
- searcher .search (query , collector );
197
- }
198
- hits = collector .topDocs ().scoreDocs ;
199
- for (ScoreDoc hit : hits ) {
200
- int docId = hit .doc ;
201
- Document d = searcher .doc (docId );
202
- docs .add (d );
203
- }
191
+ searchIndex (searcher , paging );
204
192
}
205
193
206
194
/**
@@ -222,6 +210,10 @@ private void searchMultiDatabase(List<Project> root, boolean paging) throws IOEx
222
210
MultiReader searchables = RuntimeEnvironment .getInstance ().
223
211
getMultiReader (projects , searcherList );
224
212
searcher = new IndexSearcher (searchables );
213
+ searchIndex (searcher , paging );
214
+ }
215
+
216
+ private void searchIndex (IndexSearcher searcher , boolean paging ) throws IOException {
225
217
collector = TopScoreDocCollector .create (hitsPerPage * cachePages );
226
218
searcher .search (query , collector );
227
219
totalHits = collector .getTotalHits ();
0 commit comments