From 907883f70197cce96ddddbff4925c75567b41c5c Mon Sep 17 00:00:00 2001 From: Perdjesk Date: Fri, 30 Jun 2023 16:14:24 +0200 Subject: [PATCH] Correct Javadocs using SimpleBindings (#12402) Javadocs were still referring the old `SortField` API, which has been replaced with methods that use `DoubleValuesSource` instead. --- .../java/org/apache/lucene/search/package-info.java | 6 +++--- .../org/apache/lucene/expressions/Expression.java | 12 ++++++------ .../lucene/expressions/TestDemoExpressions.java | 2 +- .../suggest/DocumentValueSourceDictionary.java | 4 ++-- 4 files changed, 12 insertions(+), 12 deletions(-) diff --git a/lucene/core/src/java/org/apache/lucene/search/package-info.java b/lucene/core/src/java/org/apache/lucene/search/package-info.java index 65392b13a9e..22468dbda73 100644 --- a/lucene/core/src/java/org/apache/lucene/search/package-info.java +++ b/lucene/core/src/java/org/apache/lucene/search/package-info.java @@ -301,10 +301,10 @@ * // compile an expression: * Expression expr = JavascriptCompiler.compile("_score * ln(popularity)"); * - * // SimpleBindings just maps variables to SortField instances + * // SimpleBindings just maps variables to DoubleValuesSource instances * SimpleBindings bindings = new SimpleBindings(); - * bindings.add(new SortField("_score", SortField.Type.SCORE)); - * bindings.add(new SortField("popularity", SortField.Type.INT)); + * bindings.add("_score", DoubleValuesSource.SCORES); + * bindings.add("popularity", DoubleValuesSource.fromIntField("popularity")); * * // create a query that matches based on 'originalQuery' but * // scores using expr diff --git a/lucene/expressions/src/java/org/apache/lucene/expressions/Expression.java b/lucene/expressions/src/java/org/apache/lucene/expressions/Expression.java index f6a229ffc05..8efac5191f5 100644 --- a/lucene/expressions/src/java/org/apache/lucene/expressions/Expression.java +++ b/lucene/expressions/src/java/org/apache/lucene/expressions/Expression.java @@ -31,10 +31,10 @@ import org.apache.lucene.search.SortField; * // compile an expression: * Expression expr = JavascriptCompiler.compile("sqrt(_score) + ln(popularity)"); * - * // SimpleBindings just maps variables to SortField instances + * // SimpleBindings just maps variables to DoubleValuesSource instances * SimpleBindings bindings = new SimpleBindings(); - * bindings.add(new SortField("_score", SortField.Type.SCORE)); - * bindings.add(new SortField("popularity", SortField.Type.INT)); + * bindings.add("_score", DoubleValuesSource.SCORES); + * bindings.add("popularity", DoubleValuesSource.fromIntField("popularity")); * * // create a sort field and sort by it (reverse order) * Sort sort = new Sort(expr.getSortField(bindings, true)); @@ -48,10 +48,10 @@ import org.apache.lucene.search.SortField; * // compile an expression: * Expression expr = JavascriptCompiler.compile("sqrt(_score) + ln(popularity)"); * - * // SimpleBindings just maps variables to SortField instances + * // SimpleBindings just maps variables to DoubleValuesSource instances * SimpleBindings bindings = new SimpleBindings(); - * bindings.add(new SortField("_score", SortField.Type.SCORE)); - * bindings.add(new SortField("popularity", SortField.Type.INT)); + * bindings.add("_score", DoubleValuesSource.SCORES); + * bindings.add("popularity", DoubleValuesSource.fromIntField("popularity")); * * // create a query that matches based on body:contents but * // scores using expr diff --git a/lucene/expressions/src/test/org/apache/lucene/expressions/TestDemoExpressions.java b/lucene/expressions/src/test/org/apache/lucene/expressions/TestDemoExpressions.java index 7190a46b5b8..592d1a0471b 100644 --- a/lucene/expressions/src/test/org/apache/lucene/expressions/TestDemoExpressions.java +++ b/lucene/expressions/src/test/org/apache/lucene/expressions/TestDemoExpressions.java @@ -92,7 +92,7 @@ public class TestDemoExpressions extends LuceneTestCase { // compile an expression: Expression expr = JavascriptCompiler.compile("sqrt(_score) + ln(popularity)"); - // we use SimpleBindings: which just maps variables to SortField instances + // we use SimpleBindings: which just maps variables to DoubleValuesSource instances SimpleBindings bindings = new SimpleBindings(); bindings.add("_score", DoubleValuesSource.SCORES); bindings.add("popularity", DoubleValuesSource.fromIntField("popularity")); diff --git a/lucene/suggest/src/java/org/apache/lucene/search/suggest/DocumentValueSourceDictionary.java b/lucene/suggest/src/java/org/apache/lucene/search/suggest/DocumentValueSourceDictionary.java index f912c19c24b..53b7458723d 100644 --- a/lucene/suggest/src/java/org/apache/lucene/search/suggest/DocumentValueSourceDictionary.java +++ b/lucene/suggest/src/java/org/apache/lucene/search/suggest/DocumentValueSourceDictionary.java @@ -40,8 +40,8 @@ import org.apache.lucene.search.LongValuesSource; * addition of two fields: * Expression expression = JavascriptCompiler.compile("f1 + f2"); * SimpleBindings bindings = new SimpleBindings(); - * bindings.add(new SortField("f1", SortField.Type.LONG)); - * bindings.add(new SortField("f2", SortField.Type.LONG)); + * bindings.add("f1", DoubleValuesSource.fromLongField("f1")); + * bindings.add("f2", DoubleValuesSource.fromLongField("f2")); * LongValuesSource valueSource = expression.getDoubleValuesSource(bindings).toLongValuesSource(); * */