mirror of https://github.com/apache/lucene.git
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:
parent
8811f31b9c
commit
907883f701
|
@ -301,10 +301,10 @@
|
||||||
* // compile an expression:
|
* // compile an expression:
|
||||||
* Expression expr = JavascriptCompiler.compile("_score * ln(popularity)");
|
* 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();
|
* SimpleBindings bindings = new SimpleBindings();
|
||||||
* bindings.add(new SortField("_score", SortField.Type.SCORE));
|
* bindings.add("_score", DoubleValuesSource.SCORES);
|
||||||
* bindings.add(new SortField("popularity", SortField.Type.INT));
|
* bindings.add("popularity", DoubleValuesSource.fromIntField("popularity"));
|
||||||
*
|
*
|
||||||
* // create a query that matches based on 'originalQuery' but
|
* // create a query that matches based on 'originalQuery' but
|
||||||
* // scores using expr
|
* // scores using expr
|
||||||
|
|
|
@ -31,10 +31,10 @@ import org.apache.lucene.search.SortField;
|
||||||
* // compile an expression:
|
* // compile an expression:
|
||||||
* Expression expr = JavascriptCompiler.compile("sqrt(_score) + ln(popularity)");
|
* 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();
|
* SimpleBindings bindings = new SimpleBindings();
|
||||||
* bindings.add(new SortField("_score", SortField.Type.SCORE));
|
* bindings.add("_score", DoubleValuesSource.SCORES);
|
||||||
* bindings.add(new SortField("popularity", SortField.Type.INT));
|
* bindings.add("popularity", DoubleValuesSource.fromIntField("popularity"));
|
||||||
*
|
*
|
||||||
* // create a sort field and sort by it (reverse order)
|
* // create a sort field and sort by it (reverse order)
|
||||||
* Sort sort = new Sort(expr.getSortField(bindings, true));
|
* Sort sort = new Sort(expr.getSortField(bindings, true));
|
||||||
|
@ -48,10 +48,10 @@ import org.apache.lucene.search.SortField;
|
||||||
* // compile an expression:
|
* // compile an expression:
|
||||||
* Expression expr = JavascriptCompiler.compile("sqrt(_score) + ln(popularity)");
|
* 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();
|
* SimpleBindings bindings = new SimpleBindings();
|
||||||
* bindings.add(new SortField("_score", SortField.Type.SCORE));
|
* bindings.add("_score", DoubleValuesSource.SCORES);
|
||||||
* bindings.add(new SortField("popularity", SortField.Type.INT));
|
* bindings.add("popularity", DoubleValuesSource.fromIntField("popularity"));
|
||||||
*
|
*
|
||||||
* // create a query that matches based on body:contents but
|
* // create a query that matches based on body:contents but
|
||||||
* // scores using expr
|
* // scores using expr
|
||||||
|
|
|
@ -92,7 +92,7 @@ public class TestDemoExpressions extends LuceneTestCase {
|
||||||
// compile an expression:
|
// compile an expression:
|
||||||
Expression expr = JavascriptCompiler.compile("sqrt(_score) + ln(popularity)");
|
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();
|
SimpleBindings bindings = new SimpleBindings();
|
||||||
bindings.add("_score", DoubleValuesSource.SCORES);
|
bindings.add("_score", DoubleValuesSource.SCORES);
|
||||||
bindings.add("popularity", DoubleValuesSource.fromIntField("popularity"));
|
bindings.add("popularity", DoubleValuesSource.fromIntField("popularity"));
|
||||||
|
|
|
@ -40,8 +40,8 @@ import org.apache.lucene.search.LongValuesSource;
|
||||||
* addition of two fields: <code>
|
* addition of two fields: <code>
|
||||||
* Expression expression = JavascriptCompiler.compile("f1 + f2");
|
* Expression expression = JavascriptCompiler.compile("f1 + f2");
|
||||||
* SimpleBindings bindings = new SimpleBindings();
|
* SimpleBindings bindings = new SimpleBindings();
|
||||||
* bindings.add(new SortField("f1", SortField.Type.LONG));
|
* bindings.add("f1", DoubleValuesSource.fromLongField("f1"));
|
||||||
* bindings.add(new SortField("f2", SortField.Type.LONG));
|
* bindings.add("f2", DoubleValuesSource.fromLongField("f2"));
|
||||||
* LongValuesSource valueSource = expression.getDoubleValuesSource(bindings).toLongValuesSource();
|
* LongValuesSource valueSource = expression.getDoubleValuesSource(bindings).toLongValuesSource();
|
||||||
* </code>
|
* </code>
|
||||||
*/
|
*/
|
||||||
|
|
Loading…
Reference in New Issue