From 6aa312a8db194771ee49922907d2b534728688cb Mon Sep 17 00:00:00 2001 From: Christine Poerschke Date: Wed, 18 Oct 2017 13:18:40 +0100 Subject: [PATCH] LUCENE-7991: KNearestNeighborDocumentClassifier.knnSearch no longer applies a previous boosted field's factor to subsequent unboosted fields. --- lucene/CHANGES.txt | 7 ++++++- .../document/KNearestNeighborDocumentClassifier.java | 1 + 2 files changed, 7 insertions(+), 1 deletion(-) 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));