Query with Nested, Location and script


(Jordan S) #1

Hi all,

I'm Jordan and i work on a search engine. I need some help writting a script...

This is a part of my query :

And the error is: "failed to run inline script [doc['services.distance'].value <= doc['location'].arcDistanceInKm(lat, lon)] using lang [groovy]"; "groovy_script_execution_exception";


(Este Demz) #2

Hi,

I have a very similar issue, if someone could help with this, it would be great.

Thanks.


(Mark Walkom) #3

Just checking, do you have scripting enabled?


(Jordan S) #4

I think...


(Mark Walkom) #5

It's a lot easier if you just paste the text, rather than a screenshot of that text.

However that looks correct.


(Jordan S) #6

I post all my query... If you see an error.

{ "query": { "bool": { "filter": [ { "nested": { "path": "stores", "query": { "bool": { "filter": [ { "match": { "stores.id": 1 } }, { "or": [ { "match": { "stores.active_distance": false } }, { "and": [ { "match": { "stores.active_distance": true } }, { "script": { "script": { "params": { "lat": 12.345678, "lon": 12.345678 }, "lang": "groovy", "inline": "doc['stores.distance'].value >= doc['location'].arcDistanceInKm(lat, lon)" } } } ] } ] } ] } } } }, { "not": { "match": { "_id": 2 } } } ] } } }


(system) #7