1

I'm creating an ElasticSearch native script, and I'm struggling to get a List<String> value of some field in my doc.

Here is what I tried:

List<String> tmp = ((ScriptDocValues.Strings) doc().get("my_field")).getValues();

And here is the exception thrown:

java.lang.NoSuchMethodError: org.elasticsearch.index.fielddata.ScriptDocValues$Strings.getValues()Lorg/elasticsearch/index/fielddata/util/StringArrayRef;

I can't figure out why it doesn't work, given the code of this module...

1
  • if your class is compiling, and you have such an error at runtime, then you probably have another (older...) version of this class in your classpath at runtime ... Just a idea, i'm not sure... Commented Jun 11, 2013 at 18:09

1 Answer 1

1

You compiled your code with an older version of elasticsearch (0.20.x or older) than the one you're using at runtime (0.90.x).

The error you get says that the not found method has a StringArrayRef return type. It seems weird since you assign the result to a List<String>, but that works at compile time since the StringArrayRef class extended AbstractList<String> before it was removed from the elasticsearch codebase. I guess the method was removed during the fielddata refactoring that has been done a few months ago. The method that you see on master and 0.90.x returns now a List<String>. Just update your elasticsearch dependency (use the same that you're using at runtime), recompile and you should be good to go!

Sign up to request clarification or add additional context in comments.

1 Comment

Perfectly right. I forgot to change my Maven dependencies for compilation... Thanks a lot!

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.