11.05.2016 Views

Apache Solr Reference Guide Covering Apache Solr 6.0

21SiXmO

21SiXmO

SHOW MORE
SHOW LESS

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

In general, the JSON update syntax supports all of the update commands that the XML update handler supports,<br />

through a straightforward mapping. Multiple commands, adding and deleting documents, may be contained in<br />

one message:<br />

curl -X POST -H 'Content-Type: application/json'<br />

'http://localhost:8983/solr/my_collection/update' --data-binary '<br />

{<br />

"add": {<br />

"doc": {<br />

"id": "DOC1",<br />

"my_boosted_field": { /* use a map with boost/value for a boosted field<br />

*/<br />

"boost": 2.3,<br />

"value": "test"<br />

},<br />

"my_multivalued_field": [ "aaa", "bbb" ] /* Can use an array for a<br />

multi-valued field */<br />

}<br />

},<br />

"add": {<br />

"commitWithin": 5000, /* commit this document within 5 seconds */<br />

"overwrite": false,<br />

/* don't check for existing documents with the<br />

same uniqueKey */<br />

"boost": 3.45, /* a document boost */<br />

"doc": {<br />

"f1": "v1",<br />

/* Can use repeated keys for a multi-valued field<br />

*/<br />

"f1": "v2"<br />

}<br />

},<br />

"commit": {},<br />

"optimize": { "waitSearcher":false },<br />

"delete": { "id":"ID" }, /* delete by ID */<br />

"delete": { "query":"QUERY" } /* delete by query */<br />

}'<br />

Comments are not allowed in JSON, but duplicate names are.<br />

The comments in the above example are for illustrative purposes only, and can not be included in actual<br />

commands sent to <strong>Solr</strong>.<br />

As with other update handlers, parameters such as commit, commitWithin, optimize, and overwrite may<br />

be specified in the URL instead of in the body of the message.<br />

The JSON update format allows for a simple delete-by-id. The value of a delete can be an array which contains<br />

a list of zero or more specific document id's (not a range) to be deleted. For example, a single document:<br />

{ "delete":"myid" }<br />

Or a list of document IDs:<br />

{ "delete":["id1","id2"] }<br />

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

189

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

Saved successfully!

Ooh no, something went wrong!