ElasticSearch 2.4 - Query String OR between main type and nested
You can do that with bool
query. Your query will look something like this:
POST example_contact_purchases/contact/_search{ "query": { "bool": { "should": [ { "query_string": { "query": "country:ES" } }, { "nested": { "path": "purchases", "filter": { "query": { "query_string": { "query": "(purchases.uuid:45)" } } } } } ] } }}
Notice that should
== OR
in this case.
Also, since you are querying these fields (country
and purchases.uuid
) by exact value you may consider setting them as not_analyzed
(or keyword
in modern versions of Elasticsearch) and use exact match query like term
.
Hope that helps!