Reputation: 57
i have an issue with solr. i have to update a single field value in multiple solr docs, like we update on DB "update customer set country='India' where city='Delhi'"
"docs": [ { "classId": "23003", "status": 1, "notificationId": 27057, "isRead": 0 }, { "classId": "23003", "status": 1, "notificationId": 42001, "isRead": 0 }, { "classId": "23003", "status": 1, "notificationId": 27060, "isRead": 0 }, { "classId": "62277", "status": 1, "notificationId": 72327, "isRead": 0 } ]
i have to update status = 0, where classId=23003.
Please help me how can i do this.
Upvotes: 0
Views: 1520
Reputation: 52822
No, updating multiple documents in a single request is not supported in Solr.
You'll have to retrieve the list of documents (i.e query for city:Delhi
), then issue an atomic update for each one:
[
{"notificationId":"retrievedId1", "status":{"set": 0}},
{"notificationId":"retrievedId2", "status":{"set": 0}},
]
Include the _version_
parameter from each document to avoid overwriting changes made by other threads in the meantime (optimistic concurrency) if necessary.
Upvotes: 5