0

We want to have a solution to compare a nested key value with root level field. Can we access a nested key value for filter(script)? We can get value from script field(parms), but we can't use parms in filter function. Only doc can be used from my knowledge, but doc in filter script we can't access nested structure. If doc under nested path, the meanwhile we can't access root level field.

Thomas Hansen
  • 775
  • 1
  • 6
  • 17
Jeff
  • 117
  • 10

1 Answers1

0

You could leverage the copy_to / include_in_root parameters in order to allow _source access in a script, as I've outlined in my answer to How to iterate through a nested array in elasticsearch with filter script?

Alternatively, you could hijack a function_score query which, unlike standard filters, still has access to params._source without any mapping adjustments. Discussed in more detail in this thread.

Joe - GMapsBook.com
  • 15,787
  • 4
  • 23
  • 68