Index: trunk/lucene-search-3/src/main/java/org/wikimedia/lsearch/search/MatchAllTitlesQuery.java |
— | — | @@ -17,6 +17,9 @@ |
18 | 18 | * limitations under the License. |
19 | 19 | */ |
20 | 20 | |
| 21 | +import java.io.IOException; |
| 22 | +import java.util.Set; |
| 23 | + |
21 | 24 | import org.apache.lucene.index.IndexReader; |
22 | 25 | import org.apache.lucene.search.ComplexExplanation; |
23 | 26 | import org.apache.lucene.search.Explanation; |
— | — | @@ -27,9 +30,6 @@ |
28 | 31 | import org.apache.lucene.search.Weight; |
29 | 32 | import org.apache.lucene.util.ToStringUtils; |
30 | 33 | |
31 | | -import java.io.IOException; |
32 | | -import java.util.Set; |
33 | | - |
34 | 34 | /** |
35 | 35 | * A query that matches all documents, and gets scores from title boost |
36 | 36 | * |
— | — | @@ -94,10 +94,28 @@ |
95 | 95 | |
96 | 96 | } |
97 | 97 | |
98 | | - private class MatchAllDocsWeight implements Weight { |
| 98 | + private class MatchAllDocsWeight extends Weight { |
| 99 | + |
| 100 | + @Override |
| 101 | + public Scorer scorer(IndexReader reader, boolean arg1, boolean arg2) |
| 102 | + throws IOException { |
| 103 | + |
| 104 | + return new MatchAllScorer(reader, similarity, this, reader.norms(titleField)); |
| 105 | + } |
| 106 | + |
99 | 107 | /** |
100 | 108 | * |
101 | | - */ |
| 109 | + * @param reader |
| 110 | + * @return |
| 111 | + * @throws IOException |
| 112 | + * |
| 113 | + * @Deprecated |
| 114 | + */ |
| 115 | + public Scorer scorer(IndexReader reader) throws IOException { |
| 116 | + return new MatchAllScorer(reader, similarity, this, reader.norms(titleField)); |
| 117 | + } |
| 118 | + |
| 119 | + |
102 | 120 | private static final long serialVersionUID = 3242930691905297732L; |
103 | 121 | private Similarity similarity; |
104 | 122 | private float queryWeight; |
— | — | @@ -107,18 +125,31 @@ |
108 | 126 | this.similarity = searcher.getSimilarity(); |
109 | 127 | } |
110 | 128 | |
| 129 | + /** |
| 130 | + * |
| 131 | + */ |
| 132 | + @Override |
111 | 133 | public String toString() { |
112 | 134 | return "weight(" + MatchAllTitlesQuery.this + ")"; |
113 | 135 | } |
114 | | - |
| 136 | + /** |
| 137 | + * |
| 138 | + */ |
| 139 | + @Override |
115 | 140 | public Query getQuery() { |
116 | 141 | return MatchAllTitlesQuery.this; |
117 | 142 | } |
118 | | - |
| 143 | + /** |
| 144 | + * |
| 145 | + */ |
| 146 | + @Override |
119 | 147 | public float getValue() { |
120 | 148 | return queryWeight; |
121 | 149 | } |
122 | | - |
| 150 | + /** |
| 151 | + * |
| 152 | + */ |
| 153 | + @Override |
123 | 154 | public float sumOfSquaredWeights() { |
124 | 155 | queryWeight = getBoost(); |
125 | 156 | return queryWeight * queryWeight; |
— | — | @@ -129,10 +160,9 @@ |
130 | 161 | queryWeight *= this.queryNorm; |
131 | 162 | } |
132 | 163 | |
133 | | - public Scorer scorer(IndexReader reader) throws IOException { |
134 | | - return new MatchAllScorer(reader, similarity, this, reader.norms(titleField)); |
135 | | - } |
136 | 164 | |
| 165 | + |
| 166 | + @Override |
137 | 167 | public Explanation explain(IndexReader reader, int doc) { |
138 | 168 | // explain query weight |
139 | 169 | Explanation queryExpl = new ComplexExplanation |
— | — | @@ -144,9 +174,13 @@ |
145 | 175 | |
146 | 176 | return queryExpl; |
147 | 177 | } |
| 178 | + |
| 179 | + |
| 180 | + |
| 181 | + |
148 | 182 | } |
149 | 183 | |
150 | | - protected Weight createWeight(Searcher searcher) { |
| 184 | + public Weight createWeight(Searcher searcher) { |
151 | 185 | return new MatchAllDocsWeight(searcher); |
152 | 186 | } |
153 | 187 | |