I have the below record:
{
"objectId": "ea5f9b14e0ca03990591de06a433a220",
"annotations": [
{
"itemDetails": {
"value": "US1",
"confidence": 1
}
},
{
"itemDetails": {
"value": "US2",
"confidence": 0.9579
}
}
]
}
annotations is nested in the above document. and value is keyword in itemDetails.
I am using the below query to fetch this record. But no results found.
{
"query": {
"nested": {
"path": "annotations",
"query": {
"bool": {
"must": [
{
"match": {
"annotations.itemDetails.value": "US1"
}
},
{
"match": {
"annotations.itemDetails.value": "US2"
}
}
]
}
}
}
}
}
Need suggestion to understand what I am doing wrong. should operation is working file but not sure whats wrong with the must
Update:
Correct me if I am wrong, From this link https://www.elastic.co/guide/en/elasticsearch/reference/current/nested.html, I see must inside the nested record will not work. Page says --> This query doesn’t match because US1
and US2
are not in the same nested object.
Big trouble now. How can I achieve the above by changing the mappings?