Apache Lucene open-source search software
SOLR-8871 - adjusted header positioning
Tommaso Teofili96489d23846a
diff --git a/lucene/classification/src/java/org/apache/lucene/classification/KNearestNeighborClassifier.java b/lucene/classification/src/java/org/apache/lucene/classification/KNearestNeighborClassifier.javaindex c4f2c2f53a5..77f04164cc3 100644--- a/lucene/classification/src/java/org/apache/lucene/classification/KNearestNeighborClassifier.java+++ b/lucene/classification/src/java/org/apache/lucene/classification/KNearestNeighborClassifier.java@@ -195,9 +195,10 @@ public class KNearestNeighborClassifier implements Classifier<BytesRef> {Map<BytesRef, Double> classBoosts = new HashMap<>(); // this is a boost based on class ranking positions in topDocsfloat maxScore = topDocs.getMaxScore();for (ScoreDoc scoreDoc : topDocs.scoreDocs) {- IndexableField storableField = indexSearcher.doc(scoreDoc.doc).getField(classFieldName);- if (storableField != null) {- BytesRef cl = new BytesRef(storableField.stringValue());+ IndexableField[] storableFields = indexSearcher.doc(scoreDoc.doc).getFields(classFieldName);+ for (IndexableField singleStorableField : storableFields) {+ if (singleStorableField != null) {+ BytesRef cl = new BytesRef(singleStorableField.stringValue());//update countInteger count = classCounts.get(cl);if (count != null) {@@ -213,6 +214,7 @@ public class KNearestNeighborClassifier implements Classifier<BytesRef> {} else {classBoosts.put(cl, singleBoost);}+ }}}List<ClassificationResult<BytesRef>> returnList = new ArrayList<>();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.javaindex 342ee0826fe..e01090a9cac 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@@ -109,6 +109,7 @@ public class KNearestNeighborDocumentClassifier extends KNearestNeighborClassifiTopDocs knnResults = knnSearch(document);List<ClassificationResult<BytesRef>> assignedClasses = buildListFromTopDocs(knnResults);Collections.sort(assignedClasses);+ max = Math.min(max, assignedClasses.size());return assignedClasses.subList(0, max);}@@ -130,15 +131,14 @@ public class KNearestNeighborDocumentClassifier extends KNearestNeighborClassifiboost = field2boost[1];}String[] fieldValues = document.getValues(fieldName);+ mlt.setBoost(true); // we want always to use the boost coming from TF * IDF of the termif (boost != null) {- mlt.setBoost(true);- mlt.setBoostFactor(Float.parseFloat(boost));+ mlt.setBoostFactor(Float.parseFloat(boost)); // this is an additional multiplicative boost coming from the field boost}mlt.setAnalyzer(field2analyzer.get(fieldName));for (String fieldContent : fieldValues) {mltQuery.add(new BooleanClause(mlt.like(fieldName, new StringReader(fieldContent)), BooleanClause.Occur.SHOULD));}- mlt.setBoost(false);}Query classFieldQuery = new WildcardQuery(new Term(classFieldName, "*"));mltQuery.add(new BooleanClause(classFieldQuery, BooleanClause.Occur.MUST));diff --git a/solr/core/src/test/org/apache/solr/update/processor/ClassificationUpdateProcessorTest.java b/solr/core/src/test/org/apache/solr/update/processor/ClassificationUpdateProcessorTest.javaindex 938dfc56582..432bb02c68b 100644--- a/solr/core/src/test/org/apache/solr/update/processor/ClassificationUpdateProcessorTest.java+++ b/solr/core/src/test/org/apache/solr/update/processor/ClassificationUpdateProcessorTest.java@@ -1,3 +1,19 @@+/*+ * Licensed to the Apache Software Foundation (ASF) under one or more+ * contributor license agreements. See the NOTICE file distributed with+ * this work for additional information regarding copyright ownership.+ * The ASF licenses this file to You under the Apache License, Version 2.0+ * (the "License"); you may not use this file except in compliance with+ * the License. You may obtain a copy of the License at+ *+ * http://www.apache.org/licenses/LICENSE-2.0+ *+ * Unless required by applicable law or agreed to in writing, software+ * distributed under the License is distributed on an "AS IS" BASIS,+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.+ * See the License for the specific language governing permissions and+ * limitations under the License.+ */package org.apache.solr.update.processor;import java.io.IOException;@@ -24,23 +40,6 @@ import org.junit.Test;import static org.hamcrest.core.Is.is;import static org.mockito.Mockito.mock;-/*- * Licensed to the Apache Software Foundation (ASF) under one or more- * contributor license agreements. See the NOTICE file distributed with- * this work for additional information regarding copyright ownership.- * The ASF licenses this file to You under the Apache License, Version 2.0- * (the "License"); you may not use this file except in compliance with- * the License. You may obtain a copy of the License at- *- * http://www.apache.org/licenses/LICENSE-2.0- *- * Unless required by applicable law or agreed to in writing, software- * distributed under the License is distributed on an "AS IS" BASIS,- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.- * See the License for the specific language governing permissions and- * limitations under the License.- */-/*** Tests for {@link ClassificationUpdateProcessor}*/