Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

Using IK participle to set useSmart on solr4.x has no effect.

2025-01-31 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >

Share

Shulou(Shulou.com)06/01 Report--

This article shows you how to use IK participle to set up useSmart on solr4.x without effect. The content is concise and easy to understand, which can definitely brighten your eyes. I hope you can get something through the detailed introduction of this article.

As we all know, due to the great changes in participle in the latest version of lucene and solr, IK participle is used on solr4.x and the thickness is set. The official version of the installation is as follows:

It is found that the strength of word segmentation is the same when indexing and query. The default is to install fine-strength word segmentation. The solution is as follows:

Package org.apache.solr.analysis

Import java.io.Reader

Import java.util.Map

Import org.apache.lucene.analysis.Tokenizer

Import org.apache.lucene.analysis.util.TokenizerFactory

Import org.apache.lucene.util.AttributeSource.AttributeFactory

Import org.wltea.analyzer.lucene.IKTokenizer

/ * *

* solve the problem of configuration useSmart failure when IK Analyzer 2012FF_hf1 is applied in solr4.x

*

* @ author lqin

* @ date 2013-12-24

* @ email qin.liang@sinovatio.com

* @ version 1.0

*

, /

Public class IKAnalyzerSolrTokenizerFactory extends TokenizerFactory {

/ * *

* Constructor to read the configuration from the parameters

* @ param args

, /

Public IKAnalyzerSolrTokenizerFactory (Map args)

{

Super (args)

AssureMatchVersion ()

/ / set word segmentation strength, useSmart=true rough strength, useSmart=false fine strength

This.setUseSmart ("true" .equals (args.get ("useSmart")

}

Private boolean useSmart

Public boolean useSmart ()

{

Return useSmart

}

Public void setUseSmart (boolean useSmart)

{

This.useSmart = useSmart

}

Public void init (Map args) {

This.useSmart = "true" .equals (args.get ("useSmart"))

}

@ Override

Public Tokenizer create (AttributeFactory factory, Reader input)

{

Tokenizer _ IKTokenizer = new IKTokenizer (input, this.useSmart)

Return _ IKTokenizer

}

}

Modify the configuration:

The above content is to use the IK participle on solr4.x to set up the solution that useSmart has no effect. Have you learned the knowledge or skills? If you want to learn more skills or enrich your knowledge reserve, you are welcome to follow the industry information channel.

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Servers

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report