Index structure suggestions

Hi,

I would like some advice on how to structure my data.

I have some products, approx 37000

{
	"name": "product1",
	"sku": "sku_1",
	"categories": ["cat1", "cat2"]
}

I have some physical stores approx 300

{
	"id": 1,
	"name": "Store1"
}

but then I have a dataset of Stock information and physical location of an item in a physical store.

{
	"StoreId": 1,
	"SKU": "sku_1",
	"stock": 100,
	"section": 1,
	"shelf": 2
}

each dataset is updated at different intervals.

Stores are rarely updated. products are delta updated roughly every hour and then one full publish every night.

Stock information is updated every 10 minutes.

this data is primarily used for showing in a search field with search as you type functionality, but also with facets and count on those.

if a user have not yet selected a physical store on the site, I do not want to show stock information but if they have, I would like to show stock and physical location of that item in the "search as you type" result.

How is a good structure for storing this data?

I was thinking about three ways to do accomplish this task.

1. Use Nested objects

2. Use Parent-Child relationships
this seems easy as all documents can be indexed separately

3. Basically merge the different objects in to one document and flatten the structure and index all of the combinations.

Using this approach I would have one document indexed per product, but with a blank storeId, so in the cases where no store is picked in the web ui, i would just search for documents where the field is blank.

this generates a lot more ( 11.137.000) documents, but doesnt give the penalty of using joins or has_child/patent queries as the other two options.

Is alot more, but flattened, documents preferred over having nested objects or parent-child relations?

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