11.05.2016 Views

Apache Solr Reference Guide Covering Apache Solr 6.0

21SiXmO

21SiXmO

SHOW MORE
SHOW LESS

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

set<br />

Modifier<br />

Usage<br />

Set or replace the field value(s) with the specified value(s), or remove the values if 'null' or<br />

empty list is specified as the new value.<br />

May be specified as a single value, or as a list for multivalued fields<br />

add<br />

Adds the specified values to a multivalued field.<br />

May be specified as a single value, or as a list.<br />

remove<br />

Removes (all occurrences of) the specified values from a multivalued field.<br />

May be specified as a single value, or as a list.<br />

removeregex<br />

Removes all occurrences of the specified regex from a multiValued field.<br />

May be specified as a single value, or as a list.<br />

inc<br />

Increments a numeric value by a specific amount.<br />

Must be specified as a single numeric value.<br />

The core functionality of atomically updating a document requires that all fields in your schema must be<br />

configured as stored="true" except for fields which are destinations -- which must be<br />

configured as stored="false". Atomic updates are applied to the document represented by the existing<br />

stored field values. If destinations are configured as stored, then <strong>Solr</strong> will attempt to index<br />

both the current value of the field as well as an additional copy from any source fields.<br />

For example, if the following document exists in our collection:<br />

{"id":"mydoc",<br />

"price":10,<br />

"popularity":42,<br />

"categories":["kids"],<br />

"promo_ids":["a123x"],<br />

"tags":["free_to_try","buy_now","clearance","on_sale"]<br />

}<br />

And we apply the following update command:<br />

{"id":"mydoc",<br />

"price":{"set":99},<br />

"popularity":{"inc":20},<br />

"categories":{"add":["toys","games"]},<br />

"promo_ids":{"remove":"a123x"},<br />

"tags":{"remove":["free_to_try","on_sale"]}<br />

}<br />

The resulting document in our collection will be:<br />

<strong>Apache</strong> <strong>Solr</strong> <strong>Reference</strong> <strong>Guide</strong> <strong>6.0</strong><br />

227

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!