I am indexing some URIs in SOLR using the UAX29URLEmailTokenizerFactory tokenizer. The problem is that some of my URIs are containing plus characters, which SOLR interprets as whitespaces and splits the URI. Can this problem be solved by some clever escaping of the ‘+’ char? I tried ‘+’ in the analyzer, but got the same results.
Here is my exact configuration of a field:
<fieldType name="text_general" class="solr.TextField" positionIncrementGap="100">
<analyzer type="index">
<tokenizer class="solr.UAX29URLEmailTokenizerFactory"/>
<filter class="solr.StopFilterFactory" ignoreCase="true" words="stopwords.txt" enablePositionIncrements="true" />
<filter class="solr.LowerCaseFilterFactory"/>
</analyzer>
<analyzer type="query">
<tokenizer class="solr.UAX29URLEmailTokenizerFactory"/>
<filter class="solr.StopFilterFactory" ignoreCase="true" words="stopwords.txt" enablePositionIncrements="true" />
<filter class="solr.SynonymFilterFactory" synonyms="synonyms.txt" ignoreCase="true" expand="true"/>
<filter class="solr.LowerCaseFilterFactory"/>
</analyzer>
</fieldType>
The solution I came up with finally makes use of the CharacterFilter as suggested above. The trick was to substitute it with the encoded char ‘%2B’. This had the effect of keeping the URI as a single token and returning it to my application in a proper state – as a ‘+’. Here is the fieldtype definition I came up with: