The main question is: Is there a convenient way to specify a multi-field match in all fields for a subquery? For a regular query, { match : { _all : "query string" }} works. This does not work in a nested query, perhaps because the nested object does not have _all?
More detailed question below:
I have a subdocument called "Parent" as follows:
{ "children" : [ { "field_a": "value_a_1", "field_b" : "value_b_1", "field_c" : [ { "field_c_a" : "value_c_a_1", "field_c_b" : "value_c_b_1" } ] }, { "field_a": "value_a_2", "field_b" : "value_b_2", "field_c" : [ { "field_c_a" : "value_c_a_2", "field_c_b" : "value_c_b_2" } ] } ] }
This is the mapping I used to create child objects:
"Parent" : { "properties" : { "children" : { "type" : "nested", "include_in_parent" : true } } }
And here is a query in which I want to select several terms, using a match on the request of all child fields, and a query for terms:
"query" : { "nested": { "path" : "children", "query" : { "bool" : { "must" : [ {"multi_match" : {"query": "value_c_a_1", "fields" : ["children.*"]}}, {"term" : {children.field_a : "value_a_1" }} ] } } } }
The above request does not work because I cannot select all the fields in the multimatch request for a nested object.
"query" : { "nested": { "path" : "children", "query" : { "bool" : { "must" : [ {"multi_match" : {"query": "value_c_a_1", "fields" : ["*_c_a"]}} ] } } } }
The executed query works because pattern matching allows you to put * in front of the line, but not for any reason (?)
Is there a good shortcut way to select all fields of a nested object?
It would also be nice to know why the expected children. * wildcard is not working properly.