【问题标题】:Elasticsearch, how to update a specific nested array field documents which qualify certain criteria?Elasticsearch,如何更新符合某些条件的特定嵌套数组字段文档?
【发布时间】:2017-01-07 07:47:45
【问题描述】:

我对 Elasticsearch 还很陌生: 我有一个 Elasticsearch 映射,旨在容纳来自高度规范化的 SQL Server 数据库的数据。 每次进行结构更改(映射更改)时,我都会加载数百万条记录。这有时会非常庞大​​和缓慢,需要数天才能完成。 我正在尝试找到一种方法来部分更新嵌套数组和嵌套对象字段,而无需索引整个索引数据。

这就是我的映射的样子:

{
    "Product": {
        "dynamic": "strict",
        "properties": {
            "ProductID": {
                "type": "integer"
            },
            "ProductCategory": {
                "index": "not_analyzed",
                "type": "string"
            },
            "TotalNumberOfProduct": {
                "type": "float"
            },
            "MetalProduct": {
                "type": "nested",
                "properties": {
                    "MetalProductCategory": {
                        "index": "not_analyzed",
                        "type": "string"
                    },
                    "MetalProductDescription": {
                        "index": "not_analyzed",
                        "type": "string"
                    },
                    "MetalProductID": {
                        "type": "integer"
                    }
                }
            }
        }
    }
}

我可以在一个 Product 文档下有多个 MetalProducts 嵌套数组文档。 例如。在 ProductID 001 下,我可以拥有 MetalProductID=222 MetalProductID=333。如何更新 ProductID=001 下的一个特定嵌套文档 (MetalProductID=222)?感谢您的帮助。

【问题讨论】:

标签: arrays api elasticsearch nested updates


【解决方案1】:

您需要 _id 之前插入的文档来更新它。无论如何,弹性搜索都必须重新索引新数据,但这一次,它只能在分片内工作,而不是整个数据。 https://www.elastic.co/guide/en/elasticsearch/guide/current/partial-updates.html

【讨论】:

  • 我总是明确分配_id。我的问题是如何更新该 _id 下提到嵌套对象的唯一标识符字段的单个嵌套字段。
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多