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