DEV Community

loading...

which one to use. Elassticsearch nested doc or separate index?

R🅰♓ÜL 🅿®🅰SAÐ
I'm a self taught #android and #Java developer and looking forward to learn more cool stuffs in programming.
・1 min read

Can anyone please help. I'm bit confused about which one to use for storing rating and comments for a product. It's should be in a nested document of product or in separate index

Discussion (2)

Collapse
mt3o profile image
mt3o

If you need something equivalent to JOIN in SQL, use a nested document. If data is totally independent, use separate index.
You can store those in separate indices treating each "action" (like: user assigned a rating) as separate document and then update main documents with aggregated result. However, in general, what you want to do, should be done in SQL database, not in ES.

Collapse
rahulpr27 profile image
R🅰♓ÜL 🅿®🅰SAÐ Author

Thanks. I have some documents in ES index for search purpose. Now we want to add user ownership to each documents with this rating and favourite features. So not sure how to implement this one.