Elasticsearch,如何更新一个特定的嵌套数组字段文档,它符合一定的条件



我是Elasticsearch的新手:我有一个旨在容纳来自高度规范化的SQL Server数据库的数据的Elasticsearch映射。每次进行结构更改(映射更改)时,我都要处理数百万条记录的全部负载。这有时是如此庞大和缓慢,需要几天才能完成。我试图找到一种方法来部分更新嵌套数组和嵌套对象字段,而不需要索引整个索引数据。

我的映射是这样的:

{
    "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) ?谢谢你的帮助。

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

最新更新