(Storing products) Storing and retrieving items with subsets of configuration


(Michael) #1

Using Elasticsearch for storing product data

Use case

We are using Elasticsearch to store "complex" products. Specifically I store Rims and Tire products.

Mapping

We currently store a "group" of products per. hit. To be specific:

Product: Fallon C12 - Red
This product has several size variants, to simplify the case I have here a simple matrix:
42

So what we have done, which is incorrect - we know. We stored each type of variation seperately, so the product would in Elasticsearch have the fields:

  • Size: 14,15,16
  • Width: 235, 240, 245

However the issue here is, when filtering/searching for products we would have incorrect matches. If I search the following I would like to have a mapping that resultet 0 products:

  • Size: 14
  • Width: 245
    As I do not have this combination within my matrix. Instead with my current mapping I would get the product returned, as it fits with my mapping - but what I implemented is not what I intended.

My question is, how should we map this and how would our filter look in elasticsearch. I would expect that I would map the product with a nested object of "Variations", containing the sub SKU's. However, doing this I cannot figure out, how I would filter to get the expected results.

Bonus question

If I added pricing and inventory to this nested object of variations, would I also be able to return the price of the cheapest matching variantion and sort by inventory >= 4 ? (this would be very handy to us)


(Alexander Reelsen) #2

you may want to take a look at the nested datatype, along with specific type of queries and aggregations for this datatype.

Hope this helps!


(Michael) #3

Thank you Spinscale, I will look into it right away. If I have further questions to the nested query etc., could I post them in this thread?


(Michael) #4

Hi Spinscale,

It works great. Thank you for your quick reply.


(system) #5

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