在Elasticsearch(6.0.1)中是否有其他替代嵌套类型的方法

时间:2020-06-08 13:36:22

标签: elasticsearch elasticsearch-rails

我们在索引中嵌套了类型映射,在一个索引中有大约400万个文档。以下是带有示例的映射。使用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"
          }
        }
      }
}

示例

{
 "_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
        }
      ]
    }
 }

当前,按价格对产品进行排序,按价格范围查询产品尺寸,in_stock为true,is_deleted为false。 还有什么其他方法可以用来映射而不是嵌套类型,因为它会影响查询和更新嵌套文档索引时的性能。

0 个答案:

没有答案