Hi there,
I have a store and use Elasticsearch for storing products.
I need to filter products by price range. It is simple if products' price is the same to all customers, but in my case, customers from different group will see different price. It is called shared catalogs.
Shared catalog can be created or deleted anytime. It has the same products as original catalog but different price.
I have thought of two ways to do this:
- Everytime a shared catalog is created, I will add a new field price_catalog_x to all the products. When customers from catalog_x get products with price range, I will filter products by price_catalog_x range.
Fields:
product_name
price_catalog_1
price_catalog_2
...
- Everytime a shared catalog is created, I will duplicate all the original products with additional catalog ID and new price fields. When customers from catalog X get products with price range, I will filter products by catalog ID and price fields.
Fields:
product_name
catalog_id
price
What is the most efficient way to implement this case using Elasticsearch? Or Are there any better ways please? Combining with another database to do this is acceptable. Thanks!
P.s: Reason I store products in Elasticsearch because I also need to perform full text search on some fields like name, SKU.