Updating document fields

Imagine that you have a system where you store documents your users upload. In addition to this, your users can add other users to have access to the files they uploaded. Before Solr 4, you had to reindex the whole document to update it. With the release of Solr 4 and later versions, we are allowed to update a single field if we fulfill some basic requirements. This recipe will show you how to do this.

How to do it...

Let's look at the steps we need to take to update the document field:

  1. For the purpose of the recipe, let's assume we have the following index structure (put the following entries into your schema.xml file):
    <field name="id" type="string" indexed="true" stored="true" required="true" /> <field name="file" type="text_general" ...

Get Solr Cookbook - Third Edition now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.