"Fossies" - the Fresh Open Source Software Archive  

Source code changes of the file "lucene/core/src/java/org/apache/lucene/search/BoostQuery.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).

BoostQuery.java  (lucene-9.6.0-src.tgz):BoostQuery.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;
/** /**
* A {@link Query} wrapper that allows to give a boost to the wrapped query. Boo st values that are * A {@link Query} wrapper that allows to give a boost to the wrapped query. Boo st values that are
* less than one will give less importance to this query compared to other ones while values that * less than one will give less importance to this query compared to other ones while values that
* are greater than one will give more importance to the scores returned by this query. * are greater than one will give more importance to the scores returned by this query.
* *
* <p>More complex boosts can be applied by using FunctionScoreQuery in the luce ne-queries module * <p>More complex boosts can be applied by using FunctionScoreQuery in the luce ne-queries module
*/ */
public final class BoostQuery extends Query { public final class BoostQuery extends Query {
skipping to change at line 76 skipping to change at line 75
@Override @Override
public int hashCode() { public int hashCode() {
int h = classHash(); int h = classHash();
h = 31 * h + query.hashCode(); h = 31 * h + query.hashCode();
h = 31 * h + Float.floatToIntBits(boost); h = 31 * h + Float.floatToIntBits(boost);
return h; return h;
} }
@Override @Override
public Query rewrite(IndexReader reader) throws IOException { public Query rewrite(IndexSearcher indexSearcher) throws IOException {
final Query rewritten = query.rewrite(reader); final Query rewritten = query.rewrite(indexSearcher);
if (boost == 1f) { if (boost == 1f) {
return rewritten; return rewritten;
} }
if (rewritten.getClass() == BoostQuery.class) { if (rewritten.getClass() == BoostQuery.class) {
BoostQuery in = (BoostQuery) rewritten; BoostQuery in = (BoostQuery) rewritten;
return new BoostQuery(in.query, boost * in.boost); return new BoostQuery(in.query, boost * in.boost);
} }
skipping to change at line 102 skipping to change at line 101
if (boost == 0f && rewritten.getClass() != ConstantScoreQuery.class) { if (boost == 0f && rewritten.getClass() != ConstantScoreQuery.class) {
// so that we pass needScores=false // so that we pass needScores=false
return new BoostQuery(new ConstantScoreQuery(rewritten), 0f); return new BoostQuery(new ConstantScoreQuery(rewritten), 0f);
} }
if (query != rewritten) { if (query != rewritten) {
return new BoostQuery(rewritten, boost); return new BoostQuery(rewritten, boost);
} }
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.MUST, this)); query.visit(visitor.getSubVisitor(BooleanClause.Occur.MUST, this));
} }
@Override @Override
public String toString(String field) { public String toString(String field) {
StringBuilder builder = new StringBuilder(); StringBuilder builder = new StringBuilder();
 End of changes. 3 change blocks. 
4 lines changed or deleted 3 lines changed or added

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