diff --git a/lucene/CHANGES.txt b/lucene/CHANGES.txt index 02d25d1d406..7f90a7e1480 100644 --- a/lucene/CHANGES.txt +++ b/lucene/CHANGES.txt @@ -14,7 +14,12 @@ Changes in Runtime Behavior ======================= Lucene 7.2.0 ======================= -(No Changes) + +Bug Fixes + +* LUCENE-7991: KNearestNeighborDocumentClassifier.knnSearch no longer applies + a previous boosted field's factor to subsequent unboosted fields. + (Christine Poerschke) ======================= Lucene 7.1.0 ======================= diff --git a/lucene/classification/src/java/org/apache/lucene/classification/document/KNearestNeighborDocumentClassifier.java b/lucene/classification/src/java/org/apache/lucene/classification/document/KNearestNeighborDocumentClassifier.java index 88d41fcd8d2..d687722c87c 100644 --- a/lucene/classification/src/java/org/apache/lucene/classification/document/KNearestNeighborDocumentClassifier.java +++ b/lucene/classification/src/java/org/apache/lucene/classification/document/KNearestNeighborDocumentClassifier.java @@ -129,6 +129,7 @@ public class KNearestNeighborDocumentClassifier extends KNearestNeighborClassifi for (String fieldContent : fieldValues) { mltQuery.add(new BooleanClause(mlt.like(fieldName, new StringReader(fieldContent)), BooleanClause.Occur.SHOULD)); } + mlt.setBoostFactor(1);// restore neutral boost for next field } Query classFieldQuery = new WildcardQuery(new Term(classFieldName, "*")); mltQuery.add(new BooleanClause(classFieldQuery, BooleanClause.Occur.MUST));