You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
This error in FieldDefBindings: throw new IllegalArgumentException("Field \'" + name + "\' cannot be used in an expression: it was not registered with sort=true"); is essentially thrown when either the field is not virtual or is a field (including numeric) not having doc values type DocValuesType.NUMERIC. So this error can even be thrown if either the field was not numeric, or was numeric but multivalued, or was numeric but doc values were not stored. Adding sort: true for the fields in such cases will still keep throwing this error. We can probably change this exception to reflect the required condition, i.e. the field type is not virtual or does not have NUMERIC doc values.
The text was updated successfully, but these errors were encountered:
Seems like this is an issue when trying to retrieve multivalued doc values in expressions. Lucene Bindings base class is somewhat limited in that it can return DoubleValuesSource which support only single double values.
Code flow
The issue happens when using FunctionScoreQuery, which is creates like FunctionScoreQuery(Query in, DoubleValuesSource source)
We extend Bindings class and override public DoubleValuesSource getDoubleValuesSource(String name)
DoubleValuesSource API in lucene seems to support only getting a single double value public abstract DoubleValues getValues(LeafReaderContext ctx, DoubleValues scores) throws IOException
We can have implementations our own DoubleValuesSource to support custom functions to retrieve specific value from a multivalued field like
This error in FieldDefBindings:
throw new IllegalArgumentException("Field \'" + name + "\' cannot be used in an expression: it was not registered with sort=true");
is essentially thrown when either the field is not virtual or is a field (including numeric) not having doc values typeDocValuesType.NUMERIC
. So this error can even be thrown if either the field was not numeric, or was numeric but multivalued, or was numeric but doc values were not stored. Addingsort: true
for the fields in such cases will still keep throwing this error. We can probably change this exception to reflect the required condition, i.e. the field type is not virtual or does not have NUMERIC doc values.The text was updated successfully, but these errors were encountered: