I am storing Book Titles in elasticsearch and they all belong to many shops. Like this:
{
\"books\": [
{
\"id\": 1,
\"tit
You can implement above desired result using Aggregation in aggregation with top_hits aggs. ex.
aggs: {
"set": {
"terms": {
field: "id"
},
"aggs": {
"color": {
"terms": {
field: "color"
},
"aggs": {
"products": {
"top_hits": {
_source:{
"include":["size"]
}
}
}
}
},
"product": {
"top_hits": {
_source:{
"include":["productDetails"]
},
size: 1
}
}
}
}
}