Search code examples
javapythonsolrfieldtype

Multiple Tokenizer doesn't work on Solr


i'm trying to do partial searchs on solr, with the following fieldType:

<fieldType name="partial_search" class="solr.TextField" positionIncrementGap="100">
<analyzer type="index">
    <tokenizer class="solr.KeywordTokenizerFactory"/>
    <tokenizer class="solr.NGramTokenizerFactory" minGramSize="2" maxGramSize="10"/>
</analyzer>
<analyzer type="query">
    <tokenizer class="solr.KeywordTokenizerFactory"/>
</analyzer>

But i'm getting this error:

Index: org.apache.solr.common.SolrException:org.apache.solr.common.SolrException: Could not load conf for core Index: Plugin init failure for [schema.xml] fieldType "partial_search": Plugin init failure for [schema.xml] analyzer/tokenizer: The schema defines multiple tokenizers for: [tokenizer: null]. Schema file is /var/solr/data/Index/conf/schema.xml

P.S: Index is the name of the Solr Core.


Solution

  • You can't have multiple tokenizers in the same analyzer. One solution is to apply an analyzer to your field partial_search. Make a copy field from partial_search and apply a second analyzer to that copy field. Another solution is to create a custom tokenizer which wraps behaviors from the two tokenizers you want to combine.