I have an integer value in SOLR/Lucen.
When I search for values in it, people might add a prefix to the query:
The field is an ID. So for item with id=900, people might search “900” or “it900” or “it-900” Since this is how we represent items (categort +’-‘+id).
Right now, I strip all none numeric characters in my code. Seems to me logically there should be a simple way in the SOLR schema to make this happen.
I tried defining a query analyzer for an integer field. But, Lucen does not like analyzers for INT fields
error message:
FieldType: TrieIntField (int) does not support specifying an analyzer
The field is (The analyzer is not working, as written above)
<fieldType name="int" class="solr.TrieIntField" precisionStep="0" omitNorms="true" positionIncrementGap="0">
<analyzer type="query">
<tokenizer class="solr.WhitespaceTokenizerFactory"/>
<filter class="solr.PatternReplaceFilterFactory" pattern="(\d+)" replacement="$1" />
</analyzer>
</fieldType>
Any idea how I define this?
Can you specify the filter on (say) a text field instead, and then copy the contents of that string field to an int field? That seems like the simplest way of handling it.