I need to do filter by shopIds, say shopId 1 and shopId 2. Then aggregate that data per document, so for document above the average guitar price for shopId1 and shopId2 is 150.
I then want to only return documents and values that meed a criteria, so I say shopId1 + shopId2 AND average price >130.
I am able to get some aggregation working but it is aggregation across all the documents returned, not per document.
In a nested structure, each child entry is its own document. In this way, it makes doing nested aggregations a little interesting.
I worry about the use of nested in this fashion if these lists are going to grow/change. Have you considered changing the index mapping to be "item" centric instead of the current "profile" centric?
This would give you an individual document for each inventory item and significantly more flexible queries for what you're looking to accomplish.
While it may seem more voluminous, under the hood, the number of documents will be similar, yet easier to manage and it will scale better as you grow the index.
Apache, Apache Lucene, Apache Hadoop, Hadoop, HDFS and the yellow elephant
logo are trademarks of the
Apache Software Foundation
in the United States and/or other countries.