Hi!
I would like to ask you about best solution for searching/sorting within elasticsearch. Let’s imagine catalog about 50 00+ cards.
Each card has got price within dimension of pricelist about 20 pricelist. So I created documents like this:
{
“catalog_number”: “XYZ”,
“url”: “http://xyz”,
“…”: “…”,
“price”: [
{“pricelist”: {“id”: “X”, “name”: “pricelist_a”}, “value”: 5000, “currency”: {“key”: “EUR”, “id”: “X”}},
{“pricelist”: {“id”: “Y”, “name”: “pricelist_b”}, “value”: 4900, “currency”: {“key”: “EUR”, “id”: “X”}},
{“pricelist”: {“id”: “Z”, “name”: “pricelist_c”}, “value”: 4800, “currency”: {“key”: “EUR”, “id”: “X”}}
, … 20 times …
]
}
Then we wouldlike to create user specific prices and here come my case. Imagine 5 000+ users with specific prices with each pricelist dimension.
{
“catalog_number”: “XYZ”,
“url”: “http://xyz”,
“…”: “…”,
“price”: [
{“pricelist”: {“id”: “X”, “name”: “pricelist_a”}, “value”: 5000, “currency”: {“key”: “EUR”, “id”: “X”}},
{“pricelist”: {“id”: “Y”, “name”: “pricelist_b”}, “value”: 4900, “currency”: {“key”: “EUR”, “id”: “X”}},
{“pricelist”: {“id”: “Z”, “name”: “pricelist_c”}, “value”: 4800, “currency”: {“key”: “EUR”, “id”: “X”}}
, … 20*5000 times … ?!
]
}
First I come with idea of parent-child document, which would be fine parent document (card) would not be overwritten each time price changed and parent document size wolud be keep small. But I cannot sort parents document by value of child document.
Now let’s imagine e-shop and signed-in user. User see cards and click on sort by price. Which solution do you suggest to me?
a) store price within same document (large documents + version change each time price) but sorting works
b) parent-child document size and amount of prices is good but sorting not working
c) ?
Thanks for any ideas or suggestions.