Ik extension supports Solr configuration and ik extension Solr Configuration

Source: Internet
Author: User

Ik extension supports Solr configuration and ik extension Solr Configuration

Extend ik native code:
Public class IKAnalyzerTokenizerFactory extends TokenizerFactory
{
Private boolean useSmart;

Public boolean useSmart ()
{
Return this. useSmart;
}

Public void setUseSmart (boolean useSmart ){
This. useSmart = useSmart;
}

Public IKAnalyzerTokenizerFactory (Map <String, String> args ){
Super (args );
AssureMatchVersion ();
SetUseSmart (String) args. get ("useSmart"). toString (). equals ("true "));
}

Public Tokenizer create (AttributeSource. AttributeFactory, Reader input)
{
Tokenizer _ IKTokenizer = new IKTokenizer (input, this. useSmart );
Return _ IKTokenizer;
}
}

Re-package ik. The configuration information in solr is as follows:

<fieldType name="text_ik" class="solr.TextField"><analyzer type="index"><tokenizer class="org.wltea.analyzer.lucene.IKAnalyzerTokenizerFactory" useSmart="false"/><filter class="solr.SynonymFilterFactory" synonyms="synonyms.txt" ignoreCase="true" expand="true"/><filter class="solr.StopFilterFactory" ignoreCase="true" words="stopwords.txt" /></analyzer> <analyzer type="query"><tokenizer class="org.wltea.analyzer.lucene.IKAnalyzerTokenizerFactory" useSmart="true"/><filter class="solr.SynonymFilterFactory" synonyms="synonyms.txt" ignoreCase="true" expand="true"/><filter class="solr.StopFilterFactory" ignoreCase="true" words="stopwords.txt" /></analyzer></fieldType>

  

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.