New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
script_score comparison operators failing on 1.4.1 #8828
Comments
@dakrone do you have any ideas? I made the script accessor a |
@rjernst the ScriptAccessor needs to implement Comparable in order to work with diff --git a/src/main/java/org/elasticsearch/script/ScoreAccessor.java b/src/main/java/org/elasticsearch/script/ScoreAccessor.java
index 93536e5..e8c4333 100644
--- a/src/main/java/org/elasticsearch/script/ScoreAccessor.java
+++ b/src/main/java/org/elasticsearch/script/ScoreAccessor.java
@@ -30,7 +30,7 @@ import java.io.IOException;
* The provided {@link DocLookup} is used to retrieve the score
* for the current document.
*/
-public final class ScoreAccessor extends Number {
+public final class ScoreAccessor extends Number implements Comparable<Number> {
Scorer scorer;
@@ -65,4 +65,9 @@ public final class ScoreAccessor extends Number {
public double doubleValue() {
return score();
}
+
+ @Override
+ public int compareTo(Number o) {
+ return Float.compare(this.score(), o.floatValue());
+ }
} And then the |
+1 for @dakrone fix |
Hi,
We recently upgraded from v1.3.2 to v1.4.1. A
function_score
query usingscript_score
is now failing when using>
or<
operators on the_score
. Our script worked fine in 1.3, but after upgrading to 1.4.1 it fails with the followingGroovyRuntimeException
:Not sure if this is a bug in Groovy or we need to change our script syntax to be compatible. Here are some sample steps to reproduce.
The following query fails:
Interestingly, the query works when using the
==
operator. :Also, using
compareTo
seems to work:We're OK with updating our scripts to use
compareTo
to make everything work, but we'd prefer to use the simpler<
>
syntax. I wanted to file this issue in case it's an actual bug or in case someone else comes across it.The text was updated successfully, but these errors were encountered: