solrcloud Add document, configure Chinese word segmentation
Previous article wrote how to build Solrlcoud service and based on the default configuration for a simple query, and this simple query can only be fully query, not fuzzy query, today said to add Chinese word segmentation and pinyin participle
First add a few articles, and according to the structure of the article can have such as name,title,content. So we should modify the Schema.xml file before uploading the article, add name, title, content and so on field.
Next we will schema.xml some of the attributes inside, field, FieldType, DynamicField, Copyfield, analyser
FieldType: In fact, we can relate to the table field of the database, this fieldtype is the type of field, we can first define some types to provide to field use.
For example:
<fieldtype name= "string" class= "SOLR. Strfield "sortmissinglast=" true "/>//can have many properties in FieldType: Sortmissinglast set to True no data for the field is queued after data with that field, without
The collation of the pipe request is set to False by default. Sortmissingfirst with the top upside down.
The default is set to False for the Analyzer field type specified by the word breaker <field name= "name" type= "string" indexed= "true" stored= "true"/> The Name field is named FieldType indexed, which is defined above as the default true.
Note that this data should be searched and sorted, and if the data is not indexed, then stored should be true. Stored default true. Indicates that this field is appropriate for inclusion in search results. If the data is not stored, then indexed should be true. If you want the highlight to be set to true after the search is omitnorms the length of the field does not affect the score and does not make boost at index, set it to true.
The general text field is not set to true.
Termvectors should be set to true if the field is used to make more of the like this and highlight attributes. The compressed field is compressed.
This can cause indexing and search to slow down, but will reduce storage space, only Strfield and TextField are compressible, which is usually suitable for fields longer than 200 characters.
Can be set to True when the multivalued field has more than one value. <dynamicfield name= "*_i" type= "int" indexed= "true" stored= "true"/>//and field functions just as DynamicField is dynamic if later used to suffix _
All field of I is used directly and does not require a one by one definition.
Next configure the word breaker to add Word-1.3.jar and Pinyin4j-2.5.0.jar to Solr-5.3.1/server/solr-webapp/webapp/web-inf/lib
Also add analyser under the field fieldtype you think you need to search
<field name= "Demo" type= "Text_zh" indexed= "true" stored= "true" required= "true" multivalued= "false"/>
< FieldType name= "Text_zh" class= "SOLR. TextField "positionincrementgap=" >
<analyzer type= "index" >
<tokenizer class= " Org.apdplat.word.solr.ChineseWordTokenizerFactory "/>
</analyzer>
<analyzer type=" Query ">
<tokenizer class= "org.apdplat.word.solr.ChineseWordTokenizerFactory"/>
</analyzer>
</fieldType>
Finally, upload the schema.xml update to the zookeeper:
[Root@localhost solr-5.3.1]#./server/scripts/cloud-scripts/zkcli.sh-zkhost localhost:2181-cmd Upconfig-confname Demo-conf-confdir server/solr/configsets/basic_configs/conf/
Restart Solrcloud service Chinese word pinyin can be used.