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.

The value of a "delete" can be an array which contains a list of zero or more id's to be deleted. It is not a range<br />

(start and end).<br />

You can also specify _version_ with each "delete":<br />

{<br />

}<br />

"delete":"id":50,<br />

"_version_":12345<br />

You can specify the version of deletes in the body of the update request as well.<br />

JSON Update Convenience Paths<br />

In addition to the /update handler, there are a few additional JSON specific request handler paths available by<br />

default in <strong>Solr</strong>, that implicitly override the behavior of some request parameters:<br />

Path<br />

/update/json<br />

/update/json/docs<br />

Default Parameters<br />

stream.contentType=application/json<br />

stream.contentType=application/json<br />

json.command=false<br />

The /update/json path may be useful for clients sending in JSON formatted update commands from<br />

applications where setting the Content-Type proves difficult, while the /update/json/docs path can be<br />

particularly convenient for clients that always want to send in documents – either individually or as a list – with<br />

out needing to worry about the full JSON command syntax.<br />

Transforming and Indexing Custom JSON<br />

If you have JSON documents that you would like to index without transforming them into <strong>Solr</strong>'s structure, you can<br />

add them to <strong>Solr</strong> by including some parameters with the update request. These parameters provide information<br />

on how to split a single JSON file into multiple <strong>Solr</strong> documents and how to map fields to <strong>Solr</strong>'s schema. One or<br />

more valid JSON documents can be sent to the /update/json/docs path with the configuration params.<br />

Mapping Parameters<br />

These parameters allow you to define how a JSON file should be read for multiple <strong>Solr</strong> documents.<br />

split: Defines the path at which to split the input JSON into multiple <strong>Solr</strong> documents and is required if you<br />

have multiple documents in a single JSON file. If the entire JSON makes a single solr document, the path<br />

must be “/”.<br />

f: This is a multivalued mapping parameter. At least one field mapping must be provided. The format of<br />

the parameter is target-field-name:json-path. The json-path is required. The target-field<br />

-name is the <strong>Solr</strong> document field name, and is optional. If not specified, it is automatically derived from the<br />

input JSON. Wildcards can be used here, see the section Wildcards below for more information.<br />

mapUniqueKeyOnly (boolean): This parameter is particularly convenient when the fields in the input<br />

JSON are not available in the schema and schemaless mode is not enabled. This will index all the fields<br />

into the default search field (using the df parameter, below) and only the uniqueKey field is mapped to<br />

the corresponding field in the schema. If the input JSON does not have a value for the uniqueKey field<br />

then a UUID is generated for the same.<br />

df: If the mapUniqueKeyOnly flag is used, the update handler needs a field where the data should be<br />

indexed to. This is the same field that other handlers use as a default search field.<br />

srcField: This is the name of the field to which the JSON source will be stored into. This can only be used<br />

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

190

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

Saved successfully!

Ooh no, something went wrong!