Imagine that you have a system where you store a document your users upload. In addition to that, your users can add other users to have access to the files they uploaded. As you probably know, before Solr 4.0, when you wanted to update a single field in a document you had to re-index the whole document. Solr 4.0 allows you to update a single field if you fulfill some basic requirements. So let's see how we can do that in Solr 4.0.
For the purpose of the recipe, let's assume we have the following index structure (put the following entries to your schema.xml
file's fields
section):
<field name="id" type="string" indexed="true" stored="true" required="true" /> <field name="file" type="text_general" indexed="true" stored="true"/> <field name="user" type="string" indexed="true" stored="true" multiValued="true" />
In addition to that, we need the _version_
field:
<field name="_version_" type="long" indexed="true" stored...