CopyPastor

Detecting plagiarism made easy.

Score: -1; Reported for: Open both answers

Possible Plagiarism

Plagiarized on 2018-02-18
by Dario Balinzo

Original Post

Original - Posted on 2017-07-18
by Val



            
Present in both answers; Present only in the new answer; Present only in the old answer;

You can try with a bool query, where you specify how many nested query you need in the must section:
GET test_nested/test/_search { "query": { "bool": { "must": [ {"nested" : { "path" : "tags", "query" : { "bool" : { "must" : [ { "match" : {"tags.key" : "tag1"} } ] } } }}, {"nested" : { "path" : "tags", "query" : { "bool" : { "must" : [ { "match" : {"tags.key" : "tag2"} }, { "match" : {"tags.value" : "val2"} } ] } } }} ] } } }

In this case i have one nested query for selecting all documents with key "tag1" and the second nested query to select all documents with the "tag2" and "value2".
You're almost there, your `nested` query just needs to go inside the `bool/filter` clause:
{ "query": { "bool": { "filter": [ { "term": { "access_account.nid": 17, "destroyed_at": null } }, { "nested": { "path": "categories", "query": { "bool": { "filter": [ { "terms": { "categories.id": [ 15, 17 ] } } ] } } } } ] } } }

        
Present in both answers; Present only in the new answer; Present only in the old answer;