Solr - prefix query

When I search using query addr:s*

I am getting ... (this is dummy data)

addr=someword
addr=banana-sunny.or
addr=seventy
addr=salvation

      

I only want records that start with s

, but the second record in the result starts with b

.

+4


source to share


1 answer


you are probably using text analysis for your address field that splits the word into multiple tokens.
In this case, the word "banana-solar" can be divided into several tokens (bananas, solar or). Hence, searching for s * will return you the result.
If you don't want to split, define a new field type using the KeywordTokenizerFactory and other filters. eg



<fieldType name="text_string" class="solr.TextField" sortMissingLast="true" omitNorms="true">
  <analyzer>
    <tokenizer class="solr.KeywordTokenizerFactory"/>
    <filter class="solr.LowerCaseFilterFactory" />
  </analyzer>
</fieldType>

      

+4


source







All Articles