Is there any alternate way instead of nested type in elasticsearch(6.0.1)

707 Views Asked by At

We have nested type mapping in my index which has around 4 million documents in one index. Below is the mapping with example. Using Elasticsearch 6.0.1

"mappings": {
  "inventory": {
      "name" : {
        "type" : "text"
      },
      "id" : {
        "type" : "integer"
      },
      "product_sizes" : {
        "type" : "nested",
        "properties" : {
          "deleted_at" : {
            "type" : "date"
          },
          "ean_code" : {
            "type" : "keyword"
          },
          "id" : {
            "type" : "integer"
          },
          "in_stock" : {
            "type" : "boolean"
          },
          "is_deleted" : {
            "type" : "boolean"
          },
          "price" : {
            "type" : "float"
          },
          "product_id" : {
            "type" : "long"
          },
          "uom" : {
            "type" : "keyword"
          },
          "weight" : {
            "type" : "float"
          }
        }
      }
}

Example

{
 "_index" : "inventory_553",
 "_type" : "inventory",
 "_id" : "16968",
 "_score" : 1.0,
 "_source" : {
   "id" : 16968,
    "name" : "By Nature Quinoa",
    "product_sizes" : [
        {
          "id" : 14991,
          "product_id" : 16968,
          "ean_code" : "RBSDC8909",
          "uom" : "gm",
          "weight" : 500.0,
          "price" : 460.0,
          "is_deleted" : true,
          "deleted_at" : "2019-12-03T15:26:29.854+05:30",
          "in_stock" : true
        },
        {
          "id" : 14990,
          "product_id" : 16968,
          "ean_code" : "TETYC8900",
          "uom" : "gm",
          "weight" : 250.0,
          "price" : 230.0,
          "is_deleted" : true,
          "deleted_at" : "2019-12-03T15:26:29.855+05:30",
          "in_stock" : true
        }
      ]
    }
 }

Currently, sorting the products by price, querying product sizes by price range, in_stock is true, and is_deleted is false. Is there any other way by which we can do mapping instead of nested type as it is impacting the performance while querying & updating the nested document index.

0

There are 0 best solutions below