Sort by groovy _script

Hey there!

I'd like to sort my results by groovy script but i have problem selecting
the right field values from a multi valued field.

I try to select only the value at index 2 (or 10343) from a multivalued
field.

"script": "abs((doc['multi_field'].values[0] - param1)+(doc['multi_field'].values[1]

  • param2))",

How can i select the value at a specific index. Is there a way to do it
with a multivalued field or must i index the fields seperatly?

Thanks for helping

--
You received this message because you are subscribed to the Google Groups "elasticsearch" group.
To unsubscribe from this group and stop receiving emails from it, send an email to elasticsearch+unsubscribe@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/elasticsearch/1361b223-1448-49a9-98c5-eaa7c1b8859a%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Ps:

This part

"script": "abs((doc['multi_field'].values[0] - param1)+(doc['multi_field'].values[1]

  • param2))",

throws following exception

Query Failed [Failed to execute main query]]; nested:
GroovyScriptExecutionException[NullPointerException[Cannot invoke method
minus() on null object]]; }]",

Am Mittwoch, 13. August 2014 09:10:31 UTC+2 schrieb Fabian Köstring:

Hey there!

I'd like to sort my results by groovy script but i have problem selecting
the right field values from a multi valued field.

I try to select only the value at index 2 (or 10343) from a multivalued
field.

"script": "abs((doc['multi_field'].values[0] - param1)+(doc['multi_field'].values[1]

  • param2))",

How can i select the value at a specific index. Is there a way to do it
with a multivalued field or must i index the fields seperatly?

Thanks for helping

--
You received this message because you are subscribed to the Google Groups "elasticsearch" group.
To unsubscribe from this group and stop receiving emails from it, send an email to elasticsearch+unsubscribe@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/elasticsearch/b4c9febc-be70-4503-955f-4645450ffac2%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.