In the previous question , I was introduced to fields in the query_string query and how it can help me search for nested document fields.
{ "query": { "query_string": { "fields": ["*.id","id"], "query": "2" } } }
But it only works to match, what if I want to do some kind of comparison? After some reading and testing, it seems that queries like range do not support fields . Is there a way I can execute a range query, for example. on a date, above a field that can be scattered anywhere in the document hierarchy?
i.e. given the following document:
{ "id" : 1, "Comment" : "Comment 1", "date" : "2016-08-16T15:22:36.967489", "Reply" : [ { "id" : 2, "Comment" : "Inner comment", "date" : "2016-08-16T16:22:36.967489" } ] }
Does the query search in the field date (for example, date > '2016-08-16T16:00:00.000000' ), which corresponds to this document, because of the attached field without explicitly indicating the address on Reply.date ? Something like this (I know the following query is incorrect):
{ "query": { "range" : { "date" : { "gte" : "2016-08-16T16:00:00.000000", }, "fields": ["date", "*.date"] } } }
source share