18
18
*/
19
19
20
20
/*
21
- * Copyright (c) 2005, 2021 , Oracle and/or its affiliates. All rights reserved.
21
+ * Copyright (c) 2005, 2023 , Oracle and/or its affiliates. All rights reserved.
22
22
* Portions Copyright (c) 2011, Jens Elkner.
23
23
* Portions Copyright (c) 2017, 2020, Chris Fraire <[email protected] >.
24
24
*/
44
44
import org .apache .lucene .analysis .charfilter .HTMLStripCharFilter ;
45
45
import org .apache .lucene .document .DateTools ;
46
46
import org .apache .lucene .document .Document ;
47
- import org .apache .lucene .index .CorruptIndexException ;
48
47
import org .apache .lucene .index .IndexableField ;
49
48
import org .apache .lucene .index .StoredFields ;
50
49
import org .apache .lucene .search .IndexSearcher ;
@@ -76,22 +75,22 @@ private Results() {
76
75
}
77
76
78
77
/**
79
- * Create a has map keyed by the directory of the document found.
78
+ * Create a hash map keyed by the directory of the document found.
80
79
*
81
80
* @param searcher searcher to use.
82
81
* @param hits hits produced by the given searcher's search
83
82
* @param startIdx the index of the first hit to check
84
83
* @param stopIdx the index of the last hit to check
85
- * @return a (directory, hitDocument) hashmap
86
- * @throws CorruptIndexException
87
- * @throws IOException
84
+ * @return a (directory, list of hitDocument) hashmap
85
+ * @throws IOException when index cannot be read
88
86
*/
89
87
private static Map <String , ArrayList <Integer >> createMap (
90
- IndexSearcher searcher , ScoreDoc [] hits , int startIdx , long stopIdx )
91
- throws CorruptIndexException , IOException {
88
+ IndexSearcher searcher , ScoreDoc [] hits , int startIdx , long stopIdx ) throws IOException {
92
89
93
- LinkedHashMap <String , ArrayList <Integer >> dirHash =
94
- new LinkedHashMap <>();
90
+ LOGGER .log (Level .FINEST , "directory hash contents for search hits ({0},{1}):" ,
91
+ new Object []{startIdx , stopIdx });
92
+
93
+ LinkedHashMap <String , ArrayList <Integer >> dirHash = new LinkedHashMap <>();
95
94
StoredFields storedFields = searcher .storedFields ();
96
95
for (int i = startIdx ; i < stopIdx ; i ++) {
97
96
int docId = hits [i ].doc ;
@@ -102,10 +101,16 @@ private static Map<String, ArrayList<Integer>> createMap(
102
101
continue ;
103
102
}
104
103
104
+ if (LOGGER .isLoggable (Level .FINEST )) {
105
+ LOGGER .log (Level .FINEST , "{0}: {1}" , new Object []{docId , rpath });
106
+ }
107
+
105
108
String parent = rpath .substring (0 , rpath .lastIndexOf ('/' ));
106
109
ArrayList <Integer > dirDocs = dirHash .computeIfAbsent (parent , k -> new ArrayList <>());
107
110
dirDocs .add (docId );
108
111
}
112
+
113
+
109
114
return dirHash ;
110
115
}
111
116
0 commit comments