Normally, we index the data based on the entire field, and the longest field is 10 words, but there's one more thing, if we're indexing an article. At this time how to deal with this field, the word breaker is a good solution to this problem.
The SOLR server defaults to providing a word breaker for us, but the word breaker provided by Apache SOLR is not very friendly to Chinese, for example:
It separates every word of the sentence so that if you index an article, it's quite unfriendly to experience. There are many Chinese word breakers that can be perfectly integrated with SOLR, such as mmseg4j, Ikanalyzer, Ictclas, etc. This paper takes mmeseg4j as an example to introduce the use of Chinese word breaker.
The introduction of a jar package
Download the following three jar packs, Mmseg4j-analysis-1.9.1.jar, Mmseg4j-core-1.9.1.jar,mmseg4j-solr-1.9.1.jar, and put them in the directory:/usr/local/solr-4.7.2 /example/solr-webapp/webapp/web-inf/lib.
Two modification Schema.xml
2.1 The configuration code is as follows:
<!--mmseg4j--> <fieldtype name= "Text_mmseg4j_complex" class= "SOLR. TextField "positionincrementgap=" > <analyzer> <tokenizer class= "Com.chenlb.mmseg4j.solr.MMSegTok Enizerfactory "mode=" complex "dicpath=" dic "/> </analyzer> </fieldType> <fieldtype name=" text_m Mseg4j_maxword "class=" SOLR. TextField "positionincrementgap=" > <analyzer> <tokenizer class= "Com.chenlb.mmseg4j.solr.MMSegTok Enizerfactory "mode=" Max-word "dicpath=" dic "/> </analyzer> </fieldType> <fieldtype name=" Text_ Mmseg4j_simple "class=" SOLR. TextField "positionincrementgap=" > <analyzer> <!--<tokenizer class= "com.chenlb.mmseg4j.so Lr. Mmsegtokenizerfactory "mode=" simple "dicpath=" N:/opensource/apache-solr-1.3.0/example/solr/my_dic "/> Tokenizer class= "Com.chenlb.mmseg4j.solr.MMSegTokenizerFactory" mode= "simple" dicpath= "dic"/> </analyzer>
; </fIeldtype> <!--mmseg4j-->
2.2 Index effects are as follows:
Three Test
3.1 Adding test files
Add test data as follows:
3.2 View Search Results
Four summary
Chinese word breaker can improve the indexing efficiency of the sentence, the project should be reasonable use.
Statement: If no special statement, this series of blogs to solr-4.7.2 version For example, if there is a mistake, please treatise.