How should I structure my shop data?

Hello,

I am new in the elastic search and am trying to find out how it works and how can I use it for my project.

I am reading the documentation and I do not understand how I should structure my eshop data in order to insert them in the elastic search.

More specifically, a product belongs to many categories and the question is how can I create the index for these?

Currently, I have the following options:

  1. product index
    I will create an index of products and each product will include its category information. The question for this option is:
    if I want to change a category information in my shop then I need to change this information in all products that include this information in the elastic search.
  2. Category index
    I will create an index of categories and each category will include its products. The question for this option is:
    if I want to change a product information in my shop then I need to change this information in all categories that include this product in the elastic search.

Are the above options valid in the way that the elastic works?
Are there any other options to structure my data in order to avoid the above difficulties?

Best regards,
Andreas

You can either create one index with both product and category information pre-joined, like a sql mapping table between a products table that lists individual products and category table that lists individual categories. So if a product has 3 categories then this index will have 3 documents for that product.

Or you could use nested documents where the category information is at the root of the documents and product information is nested. Or vice versa. The choice will depend totally on the kind of queries you want to run and how your data gets updated.

According to me you should create a product index and use nested documents for all the category information. But when fields for a category get updated you will have to update all products that have that category.

All eCommerce catalogs which I saw before used products index. Typical numbers or products/items is few millions which allows to fully rebuild it less then in hour.

This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.