Book Image

Solr Cookbook - Third Edition

By : Rafal Kuc
Book Image

Solr Cookbook - Third Edition

By: Rafal Kuc

Overview of this book

Table of Contents (18 chapters)
Solr Cookbook Third Edition
Credits
About the Author
Acknowledgments
About the Reviewers
www.PacktPub.com
Preface
Index

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" indexed="true" stored="true"/>
    <field name="count" type="int" indexed="true" stored="true"/>
    <field name="user" type="string" indexed="true" stored="true" multiValued="true" />
  2. In addition to this, we need the _version_...