Hi,
I have created the index in elastic search with the following mapping:
PUT test
{
"mappings": {
"documents": {
"properties": {
"title": {
"type": "text",
"fields": {
"raw": {
"type": "keyword"
}
}
},
"publish_details": {
"type": "nested",
"properties": {
"environment": {
"type": "keyword"
},
"locale": {
"type": "keyword"
},
"time": {
"type": "date"
},
"version": {
"type": "integer"
}
}
}
}
}
}
}
and added documents into it. here is the list of documents:
[{
"publish_details": [{
"environment": "blt9f5867a332cbb250",
"time": "2020-06-19T05:46:15.433Z",
"locale": "hi-in",
"version": 1
},
{
"environment": "blt9f5867a332cbb250",
"time": "2020-06-19T05:46:15.433Z",
"locale": "en-us",
"version": 1
}, {
"environment": "blt9f5867a332cbb2576",
"time": "2020-06-19T05:46:15.433Z",
"locale": "en-us",
"version": 1
}
],
"title": "Entry 1"
}, {
"publish_details": [{
"environment": "blt9f5867a332cbb250",
"time": "2020-06-19T05:46:53.508Z",
"locale": "mr-in",
"version": 1
},
{
"environment": "blt9f5867a332cbb250",
"time": "2020-06-19T05:46:53.508Z",
"locale": "en-us",
"version": 1
}
],
"title": "Entry 2"
}, {
"publish_details": [{
"environment": "blt9f5867a332cbb250",
"time": "2020-06-19T05:48:24.742Z",
"locale": "mr-in",
"version": 1
},
{
"environment": "blt9f5867a332cbb250",
"time": "2020-06-19T05:48:24.742Z",
"locale": "hi-in",
"version": 1
}
],
"title": "Entry 3"
}, {
"publish_details": [{
"environment": "blt9f5867a332cbb250",
"time": "2020-06-19T05:48:57.936Z",
"locale": "mr-in",
"version": 1
},
{
"environment": "blt9f5867a332cbb250",
"time": "2020-06-19T05:48:57.936Z",
"locale": "hi-in",
"version": 1
},
{
"environment": "blt9f5867a332cbb250",
"time": "2020-06-19T05:48:57.936Z",
"locale": "en-us",
"version": 1
}
],
"title": "Entry 4"
}, {
"publish_details": [],
"title": "Entry 5"
}]
and I want the following result
[{
"publish_details": [{
"environment": "blt9f5867a332cbb250",
"time": "2020-06-19T05:46:15.433Z",
"locale": "hi-in",
"version": 1
},
{
"environment": "blt9f5867a332cbb250",
"time": "2020-06-19T05:46:15.433Z",
"locale": "en-us",
"version": 1
}, {
"environment": "blt9f5867a332cbb2576",
"time": "2020-06-19T05:46:15.433Z",
"locale": "en-us",
"version": 1
}
],
"title": "Entry 1"
}, {
"publish_details": [{
"environment": "blt9f5867a332cbb250",
"time": "2020-06-19T05:46:53.508Z",
"locale": "mr-in",
"version": 1
},
{
"environment": "blt9f5867a332cbb250",
"time": "2020-06-19T05:46:53.508Z",
"locale": "en-us",
"version": 1
}
],
"title": "Entry 2"
}, {
"publish_details": [{
"environment": "blt9f5867a332cbb250",
"time": "2020-06-19T05:48:24.742Z",
"locale": "mr-in",
"version": 1
},
{
"environment": "blt9f5867a332cbb250",
"time": "2020-06-19T05:48:24.742Z",
"locale": "hi-in",
"version": 1
}
],
"title": "Entry 3"
},
{
"publish_details": [],
"title": "Entry 5"
}
]
So How I can achieve this. want to filter nested data type documents, so What query I used here to get a proper result (for the nested data type). Kindly help me with this.