Efficient way to sort by different fields by client

I have an index named items . And we have many stores (now around 100, and in the future it may be 10,000) .

Each item has a price for each store. So item document may look like this:

  "item_id": 1,
  "description": "This is a nice item."
  "store1_price": 100,
  "store2_price": 111,
  "store3_price": 122,
  "store100_price": 200

Sometimes I sort them by store2_price, and sometimes by store999_price.

This strategy does not seem an efficient way, because number of storeN_price increases as we have more and more stores (maybe store10000_price ?).

We can put prices into a nested field, but it does not change things a lot.

Any efficient ideas to refactor this items index?
(Maybe we have to divide index, or use other middlewares)

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