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.

equest. The structure of the command is a json mapping of the standard field type definition, including the<br />

name, class, index and query analyzer definitions, etc. Details of all of the available options are described in the<br />

section <strong>Solr</strong> Field Types.<br />

For example, to create a new field type named "myNewTxtField", you can POST a request as follows:<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 />

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

Note in this example that we have only defined a single analyzer section that will apply to index analysis and<br />

query analysis. If we wanted to define separate analysis, we would replace the analyzer section in the above<br />

example with separate sections for indexAnalyzer and queryAnalyzer. As in this example:<br />

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

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

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

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

"indexAnalyzer":{<br />

"tokenizer":{<br />

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

"delimiter":"/" }},<br />

"queryAnalyzer":{<br />

"tokenizer":{<br />

"class":"solr.KeywordTokenizerFactory" }}}<br />

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

Delete a Field Type<br />

The delete-field-type command removes a field type from your schema. If the field type does not exist in<br />

the schema, or if any field or dynamic field rule in the schema uses the field type, an error is thrown.<br />

For example, to delete the field type named "myNewTxtField", you can make a POST request as<br />

follows:<br />

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

"delete-field-type":{ "name":"myNewTxtField" }<br />

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

Replace a Field Type<br />

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

76

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

Saved successfully!

Ooh no, something went wrong!