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.

curl -X POST -H 'Content-type:application/json' --data-binary '{<br />

"delete-copy-field":{ "source":"shelf", "dest":"location" }<br />

}' http://localhost:8983/solr/gettingstarted/schema<br />

Multiple Commands in a Single POST<br />

It is possible to perform one or more add requests in a single command. The API is transactional and all<br />

commands in a single call either succeed or fail together.<br />

The commands are executed in the order in which they are specified. This means that if you want to create a<br />

new field type and in the same request use the field type on a new field, the section of the request that creates<br />

the field type must come before the section that creates the new field. Similarly, since a field must exist for it to<br />

be used in a copy field rule, a request to add a field must come before a request for the field to be used as either<br />

the source or the destination for a copy field rule.<br />

The syntax for making multiple requests supports several approaches. First, the commands can simply be made<br />

serially, as in this request to create a new field type and then a field that uses that type:<br />

curl -X POST -H 'Content-type:application/json' --data-binary '{<br />

"add-field-type":{<br />

"name":"myNewTxtField",<br />

"class":"solr.TextField",<br />

"positionIncrementGap":"100",<br />

"analyzer":{<br />

"charFilters":[{<br />

"class":"solr.PatternReplaceCharFilterFactory",<br />

"replacement":"$1$1",<br />

"pattern":"([a-zA-Z])\\\\1+" }],<br />

"tokenizer":{<br />

"class":"solr.WhitespaceTokenizerFactory" },<br />

"filters":[{<br />

"class":"solr.WordDelimiterFilterFactory",<br />

"preserveOriginal":"0" }]}},<br />

"add-field" : {<br />

"name":"sell-by",<br />

"type":"myNewTxtField",<br />

"stored":true }<br />

}' http://localhost:8983/solr/gettingstarted/schema<br />

Or, the same command can be repeated, as in this example:<br />

curl -X POST -H 'Content-type:application/json' --data-binary '{<br />

"add-field":{<br />

"name":"shelf",<br />

"type":"myNewTxtField",<br />

"stored":true },<br />

"add-field":{<br />

"name":"location",<br />

"type":"myNewTxtField",<br />

"stored":true },<br />

"add-copy-field":{<br />

"source":"shelf",<br />

"dest":[ "location", "catchall" ]}<br />

}' http://localhost:8983/solr/gettingstarted/schema<br />

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

78

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

Saved successfully!

Ooh no, something went wrong!