Index: trunk/lucene-search-3/src/main/java/org/apache/lucene/search/CustomBoostQuery.java |
— | — | @@ -23,13 +23,6 @@ |
24 | 24 | import java.util.Set; |
25 | 25 | |
26 | 26 | import org.apache.lucene.index.IndexReader; |
27 | | -import org.apache.lucene.search.ComplexExplanation; |
28 | | -import org.apache.lucene.search.Explanation; |
29 | | -import org.apache.lucene.search.Query; |
30 | | -import org.apache.lucene.search.Scorer; |
31 | | -import org.apache.lucene.search.Searcher; |
32 | | -import org.apache.lucene.search.Similarity; |
33 | | -import org.apache.lucene.search.Weight; |
34 | 27 | import org.apache.lucene.util.ToStringUtils; |
35 | 28 | |
36 | 29 | /** |
— | — | @@ -91,7 +84,11 @@ |
92 | 85 | return this; |
93 | 86 | } |
94 | 87 | |
95 | | - /*(non-Javadoc) @see org.apache.lucene.search.Query#extractTerms(java.util.Set) */ |
| 88 | + /** |
| 89 | + * @see org.apache.lucene.search.Query#extractTerms(java.util.Set) |
| 90 | + * |
| 91 | + */ |
| 92 | + @Override |
96 | 93 | public void extractTerms(Set terms) { |
97 | 94 | subQuery.extractTerms(terms); |
98 | 95 | if (boostQuery!=null) { |
— | — | @@ -179,7 +176,7 @@ |
180 | 177 | } |
181 | 178 | //=========================== W E I G H T ============================ |
182 | 179 | |
183 | | - protected class CustomWeight implements Weight { |
| 180 | + protected class CustomWeight extends Weight { |
184 | 181 | /** |
185 | 182 | * |
186 | 183 | */ |
— | — | @@ -198,17 +195,24 @@ |
199 | 196 | this.similarity = getSimilarity(searcher); |
200 | 197 | } |
201 | 198 | |
202 | | - /*(non-Javadoc) @see org.apache.lucene.search.Weight#getQuery() */ |
| 199 | + /** |
| 200 | + * @see org.apache.lucene.search.Weight#getQuery() |
| 201 | + * |
| 202 | + */ |
203 | 203 | public Query getQuery() { |
204 | 204 | return CustomBoostQuery.this; |
205 | 205 | } |
206 | 206 | |
207 | | - /*(non-Javadoc) @see org.apache.lucene.search.Weight#getValue() */ |
| 207 | + /** |
| 208 | + * @see org.apache.lucene.search.Weight#getValue() |
| 209 | + */ |
208 | 210 | public float getValue() { |
209 | 211 | return getBoost(); |
210 | 212 | } |
211 | 213 | |
212 | | - /*(non-Javadoc) @see org.apache.lucene.search.Weight#sumOfSquaredWeights() */ |
| 214 | + /** |
| 215 | + * @see org.apache.lucene.search.Weight#sumOfSquaredWeights() |
| 216 | + */ |
213 | 217 | public float sumOfSquaredWeights() throws IOException { |
214 | 218 | float sum = subQueryWeight.sumOfSquaredWeights(); |
215 | 219 | if (boostWeight!=null) { |
— | — | @@ -222,7 +226,10 @@ |
223 | 227 | return sum ; |
224 | 228 | } |
225 | 229 | |
226 | | - /*(non-Javadoc) @see org.apache.lucene.search.Weight#normalize(float) */ |
| 230 | + /** |
| 231 | + * @see org.apache.lucene.search.Weight#normalize(float) |
| 232 | + * |
| 233 | + */ |
227 | 234 | public void normalize(float norm) { |
228 | 235 | norm *= getBoost(); // incorporate boost |
229 | 236 | subQueryWeight.normalize(norm); |
— | — | @@ -234,18 +241,42 @@ |
235 | 242 | } |
236 | 243 | } |
237 | 244 | } |
238 | | - |
239 | | - /*(non-Javadoc) @see org.apache.lucene.search.Weight#scorer(org.apache.lucene.index.IndexReader) */ |
| 245 | + /** |
| 246 | + * @see org.apache.lucene.search.Weight#scorer(IndexReader, boolean, boolean) |
| 247 | + */ |
| 248 | + @Override |
| 249 | + public Scorer scorer(IndexReader reader, boolean scoreDocsInOrder, boolean topScorer) throws IOException { |
| 250 | + Scorer subQueryScorer = subQueryWeight.scorer(reader,scoreDocsInOrder,topScorer); |
| 251 | + Scorer boostScorer = (boostWeight==null ? null : boostWeight.scorer(reader,scoreDocsInOrder,topScorer)); |
| 252 | + return new CustomScorer(similarity, reader, this, subQueryScorer, boostScorer); |
| 253 | + } |
| 254 | + |
| 255 | + /** |
| 256 | + * @see org.apache.lucene.search.Weight#scorer(org.apache.lucene.index.IndexReader) |
| 257 | + * |
| 258 | + * @param reader |
| 259 | + * @return |
| 260 | + * @throws IOException |
| 261 | + * |
| 262 | + * @Deprecated |
| 263 | + */ |
240 | 264 | public Scorer scorer(IndexReader reader) throws IOException { |
241 | | - Scorer subQueryScorer = subQueryWeight.scorer(reader); |
242 | | - Scorer boostScorer = (boostWeight==null ? null : boostWeight.scorer(reader)); |
| 265 | + boolean scoreDocsInOrder=true; |
| 266 | + boolean topScorer=true; |
| 267 | + Scorer subQueryScorer = subQueryWeight.scorer(reader,scoreDocsInOrder,topScorer); |
| 268 | + Scorer boostScorer = (boostWeight==null ? null : boostWeight.scorer(reader,scoreDocsInOrder,topScorer)); |
243 | 269 | return new CustomScorer(similarity, reader, this, subQueryScorer, boostScorer); |
244 | 270 | } |
245 | 271 | |
246 | | - /*(non-Javadoc) @see org.apache.lucene.search.Weight#explain(org.apache.lucene.index.IndexReader, int) */ |
| 272 | + /** |
| 273 | + * @see org.apache.lucene.search.Weight#explain(org.apache.lucene.index.IndexReader, int) |
| 274 | + * |
| 275 | + */ |
247 | 276 | public Explanation explain(IndexReader reader, int doc) throws IOException { |
248 | 277 | return scorer(reader).explain(doc); |
249 | 278 | } |
| 279 | + |
| 280 | + |
250 | 281 | } |
251 | 282 | |
252 | 283 | |