Skip to content

armgit / solr

Public Imported from GitHub
0

Apache Solr open-source search software

LUCENE-8892: add missing closing parentheses in MultiBoolFunction's description()

Munendra S Ndc16e2707b73
diff --git a/lucene/CHANGES.txt b/lucene/CHANGES.txt
index 877fcece9ac..75e50b07b1f 100644
--- a/lucene/CHANGES.txt
+++ b/lucene/CHANGES.txt
@@ -115,6 +115,8 @@ Bug Fixes
* LUCENE-8853: FileSwitchDirectory now applies best effort to place tmp files in the same
directory as the target files. (Simon Willnauer)
+* LUCENE-8892: Add missing closing parentheses in MultiBoolFunction's description() (Florian Diebold, Munendra S N)
+
Improvements
* LUCENE-7840: Non-scoring BooleanQuery now removes SHOULD clauses before building the scorer supplier
diff --git a/lucene/queries/src/java/org/apache/lucene/queries/function/valuesource/MultiBoolFunction.java b/lucene/queries/src/java/org/apache/lucene/queries/function/valuesource/MultiBoolFunction.java
index f368b4a70d1..6e905bf4f42 100644
--- a/lucene/queries/src/java/org/apache/lucene/queries/function/valuesource/MultiBoolFunction.java
+++ b/lucene/queries/src/java/org/apache/lucene/queries/function/valuesource/MultiBoolFunction.java
@@ -16,16 +16,16 @@
*/
package org.apache.lucene.queries.function.valuesource;
+import java.io.IOException;
+import java.util.List;
+import java.util.Map;
+
import org.apache.lucene.index.LeafReaderContext;
import org.apache.lucene.queries.function.FunctionValues;
import org.apache.lucene.queries.function.ValueSource;
import org.apache.lucene.queries.function.docvalues.BoolDocValues;
import org.apache.lucene.search.IndexSearcher;
-import java.io.IOException;
-import java.util.List;
-import java.util.Map;
-
/**
* Abstract {@link ValueSource} implementation which wraps multiple ValueSources
* and applies an extendible boolean function to their values.
@@ -68,6 +68,7 @@ public abstract class MultiBoolFunction extends BoolFunction {
}
sb.append(dv.toString(doc));
}
+ sb.append(')');
return sb.toString();
}
};
@@ -86,6 +87,7 @@ public abstract class MultiBoolFunction extends BoolFunction {
}
sb.append(source.description());
}
+ sb.append(')');
return sb.toString();
}
diff --git a/lucene/queries/src/test/org/apache/lucene/queries/function/TestValueSources.java b/lucene/queries/src/test/org/apache/lucene/queries/function/TestValueSources.java
index ba0e4703490..ccdb0d34f87 100644
--- a/lucene/queries/src/test/org/apache/lucene/queries/function/TestValueSources.java
+++ b/lucene/queries/src/test/org/apache/lucene/queries/function/TestValueSources.java
@@ -17,6 +17,7 @@
package org.apache.lucene.queries.function;
import java.io.IOException;
+import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import java.util.Map;
@@ -486,6 +487,31 @@ public class TestValueSources extends LuceneTestCase {
assertHits(new FunctionQuery(vs), new float[] { 0F, 0F });
assertAllExist(vs);
}
+
+ public void testMultiBoolFunction() throws Exception {
+ // verify toString and description
+ List<ValueSource> valueSources = new ArrayList<>(Arrays.asList(
+ new ConstValueSource(4.1f), new ConstValueSource(1.2f), new DoubleFieldSource("some_double")
+ ));
+ ValueSource vs = new MultiBoolFunction(valueSources) {
+ @Override
+ protected String name() {
+ return "test";
+ }
+
+ @Override
+ protected boolean func(int doc, FunctionValues[] vals) throws IOException {
+ return false;
+ }
+ };
+ assertEquals("test(const(4.1),const(1.2),double(some_double))", vs.description());
+
+ final LeafReaderContext leaf = searcher.getIndexReader().leaves().get(0);
+ FunctionValues fv = vs.getValues(ValueSource.newContext(searcher), leaf);
+ // doesn't matter what is the docId, verify toString
+ assertEquals("test(const(4.1),const(1.2),double(some_double)=0.0)", fv.toString(1));
+
+ }
public void testTF() throws Exception {
Similarity saved = searcher.getSimilarity();