Full-Text Indexing----Chinese word breaker mmseg4j

Source: Internet
Author: User
Tags apache solr solr
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&gt  
	; </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.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.