Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Solr index update by query

Tags:

solr

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?

like image 816
striker Avatar asked Feb 08 '12 11:02

striker


2 Answers

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>
like image 160
javanna Avatar answered Sep 28 '22 03:09

javanna


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.

like image 34
uncoolbob Avatar answered Sep 28 '22 02:09

uncoolbob