问题
I have a product index and a store index. The product index includes documents that include the title and description fields of a product which are queried during search. The store index includes the id, price, and quantity of the product, in addition to the store locations.
I want to search for a product, get the documents, then retrieve all the stores that include all the resulted product ids and aggregate on them.
I have tried multiple options, but was not satisfied with the results:
Joins on parent
This approach was the best in terms of results consistency since all the stores could be linked to the parent document, but it was slower for large volume of stores.
Using two indexes
This approach was significantly faster on large volume of stores, but the results were inconsistent, since I had to duplicate the product title field for the store documents, while the product search query takes into account other fields, such as, description. I can duplicate all the fields used for the search query of the product in the store document, but that will create large documents with a lot of redundancy, while also having to make sure they are all up to date with the product document info.
来源:https://stackoverflow.com/questions/61883978/consistent-search-on-two-indexes-elasticsearch