Nested documents Sorting & faceting

I am working on an E-Commerce application. Catalog Data is being served by Elastic Search.
I have document's for Product which is already indexed in Elastic Search.

Document Looks something like this (Excluded few fields for the purpose of better readability):

{
         "title" : "Product Name",
          "volume" : "200gm",
          "brand" : {
            "brand_code" : XXXX,
            "brand_name" : "Brand Name"
          },
          "@timestamp" : "2021-08-26T08:08:11.319Z",
          "store" : [
            {
              "physical_unit" : 0,
              "default_price" : 115.0,
              "_id" : "1234_111",
              "product_code" : "1234",
              "warehouse_code" : 111,
              "available_unit" : 100
            }
          ],
          "category" : {
            "category_code" : 987,
            "category_name" : "CategoryName",
            "category_url_link" : "CategoryName",
            "super_category_name" : "SuperCategoryName",
            "parent_category_name" : "ParentCategoryName"
          }
        }

Store nested object is the one where ES Query will look for price and to decide if item is in stock or Out Of Stock.

I would like to add more child objects to store (Basically data from multiple inventory). This can go up to 150 child objects for each product.
And each warehouse/store can have different price for the same product.

Functional Requirement :

  1. For any product, we should show lowest price across all warehouse.
    For EX: If a particular product has 50 store mapped to it, Elastic Search query should look into the nested object and get the value which is lowest in all 50 stores if item is available.

  2. Performance should not be degraded.

Challenges :

  1. If we start storing those many stores for each product, data will go considerably high. Will that be a problem ?
  2. What would be the efficient way to achieve the lowest price from nested document?
  3. How would facets work within nested document ? Like if i apply price range filter ES picks up the data which was not showed earlier. (It might pick the data from other store which matches the range)

We are using template to query ES.

Any help would be appreciated.

Thanks in Advance!!

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