0
votes

I am trying to add support for Simple Chinese on my Solr core. I try add the following to my schema.xml file:

<fieldType name="text_zh" class="solr.TextField" positionIncrementGap="100">
    <analyzer class="org.apache.lucene.analysis.cn.smart.SmartChineseAnalyzer"/>
</fieldType>

The get thei following error when reloading the core:

yirmi: org.apache.solr.common.SolrException:org.apache.solr.common.SolrException: Could not load conf for core yirmi: Plugin init failure for [schema.xml] fieldType "text_zh": Cannot load analyzer: org.apache.lucene.analysis.cn.smart.SmartChineseAnalyzer. Schema file is /var/solr/data/yirmi/conf/schema.xml solr: org.apache.solr.common.SolrException:org.apache.solr.common.SolrException: Could not load conf for core solr: Error loading solr config from /var/solr/data/solr/conf/solrconfig.xml

When I try

<fieldType name="text_zh" class="solr.TextField" positionIncrementGap="100">
    <!--<analyzer class="org.apache.lucene.analysis.cn.smart.SmartChineseAnalyzer"/>-->
    <analyzer>
        <tokenizer class="solr.HMMChineseTokenizerFactory"/>
        <filter class="solr.CJKWidthFilterFactory"/>
        <filter class="solr.StopFilterFactory"
                words="org/apache/lucene/analysis/cn/smart/stopwords.txt"/>
        <filter class="solr.PorterStemFilterFactory"/>
        <filter class="solr.LowerCaseFilterFactory"/>
    </analyzer>
</fieldType>

I get the following error when loading the code:

yirmi: org.apache.solr.common.SolrException:org.apache.solr.common.SolrException:

Could not load conf for core yirmi: Plugin init failure for [schema.xml] fieldType "text_zh": Plugin init failure for [schema.xml] analyzer/tokenizer: Error loading class 'solr.HMMChineseTokenizerFactory'. Schema file is /var/solr/data/yirmi/conf/schema.xml solr: org.apache.solr.common.SolrException:org.apache.solr.common.SolrException: Could not load conf for core solr: Error loading solr config from /var/solr/data/solr/conf/solrconfig.xml

How do I install the necessary plugins in order for the changes in schema.xml to work?

1
Have you added the lucene-analyzers-smartcn-x.y.z.jar file in contrib\analysis-extras\lucene-libs to the lib statement in your solrconfig.xml?MatsLindh
Added: <lib dir="../../../contrib/analysis-extras\lucene-libs" regex="lucene-analyzers-smartcn-5\.2\.1\.jar" /> but still get the same errorYirmiyahu Fischer
The log should show the library being loaded at startup - verify that it's being loaded.MatsLindh
9/6/2018, 11:58:38 AM ERROR null CoreContainer Error creating core [yirmi]: Could not load conf for core yirmi: Plugin Initializing failure for [schema.xml] fieldType. Schema file is /var/solr/data/yirmi/conf/schema.xml 9/6/2018, 11:58:38 AM ERROR null SolrCore org.apache.solr.common.SolrException: Error CREATEing SolrCore 'yirmi': Unable to create core [yirmi] Caused by: Can't set positionIncrementGap on custom analyzer class org.apache.lucene.analysis.cn.smart.SmartChineseAnalyzerYirmiyahu Fischer
Error shown when trying to re-add core Error CREATEing SolrCore 'yirmi': Unable to create core [yirmi] Caused by: Can't set positionIncrementGap on custom analyzer class org.apache.lucene.analysis.cn.smart.SmartChineseAnalyzeYirmiyahu Fischer

1 Answers

1
votes

First, make sure that you have added the library files (the lucene-analyzers-smartcn-x.y.z.jar file in contrib\analysis-extras\lucene-libs) to your lib statement in solrconfig.xml.

The startup log for Solr should show the library file being loaded.

If you get the error

Error CREATEing SolrCore 'yirmi': Unable to create core [yirmi] Caused by: Can't set positionIncrementGap on custom analyzer class org.apache.lucene.analysis.cn.smart.SmartChineseAnalyze

Remove the positionIncrementGap setting for that field type, since that setting isn't valid for custom analyzers (which this is).