"Fossies" - the Fresh Open Source Software Archive  

Source code changes of the file "lucene/core/src/java/org/apache/lucene/search/ConstantScoreQuery.java" between
lucene-9.6.0-src.tgz and lucene-9.7.0-src.tgz

About: Lucene is a Java full-text search engine (not a complete application, but rather a code library and API). Java source code.
The most recent release (9.x series).

ConstantScoreQuery.java  (lucene-9.6.0-src.tgz):ConstantScoreQuery.java  (lucene-9.7.0-src.tgz)
skipping to change at line 21 skipping to change at line 21
* Unless required by applicable law or agreed to in writing, software * Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS, * distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and * See the License for the specific language governing permissions and
* limitations under the License. * limitations under the License.
*/ */
package org.apache.lucene.search; package org.apache.lucene.search;
import java.io.IOException; import java.io.IOException;
import java.util.Objects; import java.util.Objects;
import org.apache.lucene.index.IndexReader;
import org.apache.lucene.index.LeafReaderContext; import org.apache.lucene.index.LeafReaderContext;
import org.apache.lucene.util.Bits; import org.apache.lucene.util.Bits;
/** /**
* A query that wraps another query and simply returns a constant score equal to 1 for every * A query that wraps another query and simply returns a constant score equal to 1 for every
* document that matches the query. It therefore simply strips of all scores and always returns 1. * document that matches the query. It therefore simply strips of all scores and always returns 1.
*/ */
public final class ConstantScoreQuery extends Query { public final class ConstantScoreQuery extends Query {
private final Query query; private final Query query;
skipping to change at line 43 skipping to change at line 42
public ConstantScoreQuery(Query query) { public ConstantScoreQuery(Query query) {
this.query = Objects.requireNonNull(query, "Query must not be null"); this.query = Objects.requireNonNull(query, "Query must not be null");
} }
/** Returns the encapsulated query. */ /** Returns the encapsulated query. */
public Query getQuery() { public Query getQuery() {
return query; return query;
} }
@Override @Override
public Query rewrite(IndexReader reader) throws IOException { public Query rewrite(IndexSearcher indexSearcher) throws IOException {
Query rewritten = query.rewrite(reader);
Query rewritten = query.rewrite(indexSearcher);
// Do some extra simplifications that are legal since scores are not needed on the wrapped // Do some extra simplifications that are legal since scores are not needed on the wrapped
// query. // query.
if (rewritten instanceof BoostQuery) { if (rewritten instanceof BoostQuery) {
rewritten = ((BoostQuery) rewritten).getQuery(); rewritten = ((BoostQuery) rewritten).getQuery();
} else if (rewritten instanceof ConstantScoreQuery) { } else if (rewritten instanceof ConstantScoreQuery) {
rewritten = ((ConstantScoreQuery) rewritten).getQuery(); rewritten = ((ConstantScoreQuery) rewritten).getQuery();
} else if (rewritten instanceof BooleanQuery) { } else if (rewritten instanceof BooleanQuery) {
rewritten = ((BooleanQuery) rewritten).rewriteNoScoring(); rewritten = ((BooleanQuery) rewritten).rewriteNoScoring();
} }
skipping to change at line 73 skipping to change at line 73
} }
if (rewritten.getClass() == ConstantScoreQuery.class) { if (rewritten.getClass() == ConstantScoreQuery.class) {
return rewritten; return rewritten;
} }
if (rewritten.getClass() == BoostQuery.class) { if (rewritten.getClass() == BoostQuery.class) {
return new ConstantScoreQuery(((BoostQuery) rewritten).getQuery()); return new ConstantScoreQuery(((BoostQuery) rewritten).getQuery());
} }
return super.rewrite(reader); return super.rewrite(indexSearcher);
} }
@Override @Override
public void visit(QueryVisitor visitor) { public void visit(QueryVisitor visitor) {
query.visit(visitor.getSubVisitor(BooleanClause.Occur.FILTER, this)); query.visit(visitor.getSubVisitor(BooleanClause.Occur.FILTER, this));
} }
/** /**
* We return this as our {@link BulkScorer} so that if the CSQ wraps a query w ith its own * We return this as our {@link BulkScorer} so that if the CSQ wraps a query w ith its own
* optimized top-level scorer (e.g. BooleanScorer) we can use that top-level s corer. * optimized top-level scorer (e.g. BooleanScorer) we can use that top-level s corer.
 End of changes. 3 change blocks. 
4 lines changed or deleted 4 lines changed or added

Home  |  About  |  Features  |  All  |  Newest  |  Dox  |  Diffs  |  RSS Feeds  |  Screenshots  |  Comments  |  Imprint  |  Privacy  |  HTTP(S)