如何在多个Solr文档中更新单个字段值

时间:2018-08-01 05:25:24

标签: solr

我对solr有问题。我必须在多个solr文档中更新单个字段值,就像我们在数据库上更新“ update customer set country ='India'where city ='Delhi'“

“文档”:[       {         “ classId”:“ 23003”,         “状态”:1,         “ notificationId”:27057,         “ isRead”:0       },       {         “ classId”:“ 23003”,         “状态”:1,         “ notificationId”:42001,         “ isRead”:0       },       {         “ classId”:“ 23003”,         “状态”:1,         “ notificationId”:27060,         “ isRead”:0       },       {         “ classId”:“ 62277”,         “状态”:1,         “ notificationId”:72327,         “ isRead”:0       }     ]

我必须更新状态= 0,其中classId = 23003。

请帮助我该怎么做。

1 个答案:

答案 0 :(得分:3)

否,Solr不支持在单个请求中更新多个文档。

您必须检索文档列表(即查询city:Delhi),然后为每个文档发布一个原子更新:

[
    {"notificationId":"retrievedId1", "status":{"set": 0}}, 
    {"notificationId":"retrievedId2", "status":{"set": 0}}, 
]

如有必要,同时包含其他线程制作的the _version_ parameter from each document to avoid overwriting changes(乐观并发)。

相关问题