Something like LEFT JOIN

I want to use elasticsearch for e-commerce project and have no idea how to model data of personalized products.

There is list of base products and every user can personalize each product. What is the best choice how to store data? Im thinking about parend-child relation, but problem is I need to store every product for every user. It means, if I have 10 000 products and 1 000 users I need to created 10 000 000 documents.

So I need something like LEFT JOIN and IF ELSE in SQL to not to need store every product for every user, but only products, which some user personalized it. If there is 1 user and he personalized 1 000 products (from 10 000 base products), I want to store only 1000 user products, but when I want to search products, I need something like IF EXISTS user_product USE user_product ELSE base_product and need to recieve all 10 000 base products, but if user personalized some, use user product, not base product.

Is it possible? Thanks for any clue.

You cannot do joins at all in ES.

Maybe you can store the base products in one index, then the customised ones in another - parent/child like you mentioned. Then do the join in your code.

Ok, it seems like best possible choice, but Im not very happy about that. Store all products for every user, before he personalize it, looks like expensive nonsence...

Thanks

No, store the personalised ones only.
Then when you get the product list for a customer, overwrite the default list with the exceptions.

1 Like

I have one more question, what if I need to full-text search. I need to use personalized fields for user products and base product fields for another ones. My idea is to search both index and than merge them and resort them by _score again in application. Am I right?

By the way, why did you wrote, to make 2 indexes for base and user products? I was thinking about create 2 types in same index?

Thank you very much!

Have a read of https://www.elastic.co/blog/index-vs-type