Hi,
I look the document and it works when a pair of match and range query.
The problem is I try to make multi pair of match and range query, it won't return any document.
Here is my index mapping
PUT master
{
"mappings": {
"properties": {
"masterId":{
"type": "keyword"
},
"metaData":{
"type": "object"
},
"tags": {
"type": "nested",
"properties": {
"name": {
"type": "text",
"fields": {
"keyword": {
"type": "keyword"
}
}
},
"count": { "type": "integer" }
}
}
}
}
}
Data
PUT master/_doc/docA
{
"id": "docA",
"metaData": null,
"tags": [
{
"name": "Apple",
"count": 4
},
{
"name": "Banana",
"count": 3
},
{
"name": "Cake",
"count": 2
}
]
}
PUT master/_doc/docB
{
"id": "docB",
"metaData": null,
"tags": [
{
"name": "Apple",
"count": 5
},
{
"name": "Banana",
"count": 2
},
{
"name": "Cake",
"count": 4
}
]
}
I want to find that has ( 'apple' , count >= 4 ) AND ( 'Cake', count >= 3)
I expect that return docB
My query is
(not working)
GET master/_search
{
"query": {
"nested": {
"path": "tags",
"query": {
"bool": {
"must": [
{ "match": { "tags.name": "Apple"} },
{ "range": { "tags.count": { "gte": 4 } } },
{ "match": { "tags.name": "Cake"} },
{ "range": { "tags.count": { "gte": 3 } } }
]
}
}
}
}
}
Is there any way in one query to achieve it or just need multi query?