Correct Javadocs using SimpleBindings (#12402)

Javadocs were still referring the old `SortField` API, which
has been replaced with methods that use `DoubleValuesSource`
instead.
This commit is contained in:
Perdjesk 2023-06-30 16:14:24 +02:00 committed by GitHub
parent 8811f31b9c
commit 907883f701
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 12 additions and 12 deletions

View File

@ -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

View File

@ -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

View File

@ -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"));

View File

@ -40,8 +40,8 @@ import org.apache.lucene.search.LongValuesSource;
* addition of two fields: <code>
* 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();
* </code>
*/