I need to update large amount of documents in solr very often. For example, set "online" = true for user_id = 5 and so on. But speed of indexation via http handler is very slow. Solr support delete documents by query, is there way to update by query?
No, unfortunately there isn't any feature like update by query. It would be really useful, like a new feature to make possible updating a document without the need to resubmit it entirely; there's a 5 years old jira issue for that. For now you should just re-submit your documents with the updated fields, they will be overwritten (it means deleted + re-inserted) if you use the same uniqueKey
.
By the way, are you making an http request for each document to update? If yes, you can make it faster submitting more than one document at a time like this:
<add>
<doc>
<field name="employeeId">05991</field>
<field name="office">Bridgewater</field>
</doc>
<doc>
<field name="employeeId">05992</field>
<field name="office">Bridgewater</field>
</doc>
<doc>
<field name="employeeId">05993</field>
<field name="office">Bridgewater</field>
</doc>
</add>
There's still no update by query, but the answers from 2012 are out of date. Now in Solr 4.x there are https://wiki.apache.org/solr/Atomic_Updates so you can do what you want to do in two steps without requiring access to the original document.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With