Is it possible to retrieve documents from ES, but in nested objects without records which not matching query?
My mappings:
"mappings": {
"properties": {
"prdId": {
"type": "long"
},
"prdDeleted": {
"type": "boolean"
},
"prdEAN": {
"type": "keyword",
"index": false
},
"prdCat": {
"type": "nested",
"properties": {
"catalogId": {
"type": "long"
},
"price": {
"type": "double"
},
"priceGross": {
"type": "double"
},
"vat": {
"type": "float"
},
"hasHistory": {
"type": "boolean"
}
}
},
}
}
I have list of products, and nested field prdCat where I store a list of catalogs in which a given product is located, and properties from that catalog.
If i search by nested field prdCat to get product which are in a given catalog (example catalogId = 1) i retrieve products correctly, but in nested field I have all objects, not just one where catalogId = 1
In general, I would like to reduce the size of data in response from ES, but currently I get a lot of data in the nested field that is unnecessary, one product can have several dozen catalogs.
I checked the “inner_hits” option, it works, but it adds an additional field to the returned data, which contains nested objects that match the query, “_source” field still contains whole nested objects and the finally data size is even bigger than before.
Does anyone have any ideas?
Thanks in advance.