Solr:如何使用 curl 或命令仅更新选定的字段?

Solr: How to update only selected field using curl or command?

我有如下的 Solr 文档

{
    "SKU":"1905/SHIRT DRESS-0",
    "DateCreated":["2019-08-18T15:21:04.090Z"],
    "DateModified":["2020-01-17T02:31:16.803Z"],
    "Name":"TIGRESS COLLECTION - SHIRT DRESS, SIZE 0 (6-8)",
    "Price":["249.00 AUD"],
    "PriceSale":["99.50 AUD"],
    "Size":["SIZE 0 (6-8)"],
    "StockLevel":["in stock"],
    "SubCategory":["KAFTAN"],
    "IsDeleted":[0],
    "ProductAddedOn":["2020-02-14T10:38:43.047Z"],
    "_version_":1658508251550973952
}

我只想更新此文档中的 1 个字段。

I want to update IsDeleted = 1 where ProductAddedOn is less than today's date

How to do this?

此外,我尝试使用以下命令更新名称

curl -X POST -H 'Content-Type: application/json' 'http://10.7.0.106:8983/solr/prashant1/update?_version_:1658508177093689344&versions=true&commit=true' --data-binary ' [{ "SKU" : "1905/SHIRT DRESS-0", "Name" : "update attempt with correct existing version" }]'

但是此命令会从文档中删除除名称和 SKU 之外的所有其他字段。

所以我只想更新文档中的 1 个字段,其他字段应保持原样。

Solr 支持通过 add 和 set 等字段修饰符对单个文档进行简单的原子更新(也称为部分更新)。

乐观并发控制是另一种自动更新文档的方法。

修改器 Solr 支持几个自动更新文档值的修饰符。

set – 设置或替换特定值,或者如果将 null 指定为新值则删除该值

示例:

curl http://10.224.143.172:8983/solr/knowledge_combined/update?commit=true --data-binary $'[{"id" : "1", "site_name"  : {"set":"Test new change"} }]'