gpt4 book ai didi

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

转载 作者:行者123 更新时间:2023-12-04 10:35:03 25 4
gpt4 key购买 nike

我有如下 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"} }]'

关于shell - Solr:如何使用 curl 或命令仅更新选定的字段?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/60224916/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com