Hello,
I have a question about performance of arrays that contain a large number of items (scalar values and or objects) and updating them.
We store products in ES and each product can have multiple prices as the products are from different suppliers. So we need to store prices for each supplier. So each product can have hundreds to lower thousands of prices.
The prices change quite often (several times a day) With these prices we need to be able to filter (gte, lte), so we idex them as integers ( an array of integers).
We were thinking about how we will index it:
- The first option is to store only the array of prices e.g.
"prices": [999, 1000, 1099, 1129, ...]
But here we don't see an easy way to update the price once a supplier changes the price - we have to query all the prices in the database and index the whole array of prices
again.
- The second option is to store the prices as an object with the supplier ID.
"prices": [
{
"supplierId": "<uuid1>",
"price": 999
},
{
"supplierId": "<uuid2>",
"price": 1000
},
{
"supplierId": "<uuid3>",
"price": 1099
}
]
We wanted to avoid indexing prices as nested
, since the prices
field will already be in one nested
object (product variant).
We understand that if this field is not indexed as nested
then the data will be denormalized.
"prices.supplierId": ["<uuid1>", "<uuid2>", "<uuid3>", ...],
"prices.price": [999, 1000, 1099, ...]
Is there any way to update the data (one specific price by partner ID) with respect to performance?
Or is there a more appropriate approach for these cases?
Thank you so much for your answers and your time!