1

I need to update few fields of each document in Solr index separately from the main indexing process. According to documentation "Create" and "Update" are mapped onto the "Add()" function. http://code.google.com/p/solrnet/wiki/CRUD

So if I add a document which already exist, will it replace the entire document or just the fields that I have specified?

If it'll replace the entire document then the only way that I can think of in order to update is to search the document by unique id, update the document object and then "Add" it again. This doesn't sound feasible because of the frequency of update ops required. Is there a better way to update?

Thanks!

Raza
  • 139
  • 3
  • 13

3 Answers3

4

Unfortunately, Solr does not currently support updating individual fields for a given document in the index. The later scenario you describe of retrieving the entire document contents (either from Solr or the original source) and then resending the document (adding via SolrNet) is the only way to update documents in Solr.

Please see the previous question: Update specific field on Solr index for more details about Solr not supporting individual field updates and an open JIRA issue for adding this support to Solr.

Community
  • 1
  • 1
Paige Cook
  • 22,415
  • 3
  • 57
  • 68
  • 1
    May I add that another way to update a document is to fetch it from source again, instead of fetching it from Solr and resending it, which requires all original data to be stored in Solr (typically, it's not). – Mauricio Scheffer Jan 31 '12 at 13:22
1

Partial updating of documents is now supported in the newer versions of Solr, for example 4.10 does pretty well. Please look at the following page for more information: https://cwiki.apache.org/confluence/display/solr/Updating+Parts+of+Documents

The only detail is that you need to declare your fields as stored=true to allow for partial updates.

I also show how to do it in this training: http://www.pluralsight.com/courses/enterprise-search-using-apache-solr

In this specific module: Content: Schemas, Documents and Indexing

xmorera
  • 1,933
  • 3
  • 20
  • 35
1

If you need to frequently update a lot of documents in SOLR, you might need to rethink your entire solution. In typical solutions that use SOLR and require lots of frequent updates to documents, the way it is usually done is that the documents reside in some SQL or NoSQL database, and they are modified there. Then you use DIH or something similar to bulk update the SOLR index from the database, possibly just dropping the index and re-indexing all content. SOLR can index documents very quickly so that is typically not a problem.

Robert Stewart
  • 201
  • 5
  • 10