Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Solr Query Single character

Tags:

solr

lucene

solrj

I have a fieldType which is defined as below. Now, I have defined a field 'StatusCode' of this field type which holds a Single Character like A or P. I have indexed the data using this fieldType and when I run a query like StatusCode:A it does not return any results. Can someone please explain why the query is not working on Single character fields?

<fieldType name="text_exact_fuzzy" class="solr.TextField" omitNorms="false">
      <analyzer type="index">
          <tokenizer class="solr.StandardTokenizerFactory"/>
          <filter class="solr.StandardFilterFactory"/>
          <filter class="solr.LowerCaseFilterFactory"/>
        </analyzer>
      <analyzer type="query">
        <tokenizer class="solr.StandardTokenizerFactory"/>
        <filter class="solr.StandardFilterFactory"/>
        <filter class="solr.LowerCaseFilterFactory"/>           
      </analyzer>
    </fieldType>
like image 762
Ravi Avatar asked Dec 01 '25 15:12

Ravi


1 Answers

It seems weird to define a field like StatusCode as text_exact_fuzzy and with those analyzers.

Use a simple StrField instead, without any analysis performed (only a lowercase filter factory if needed), and you should get the expected hits.

like image 59
MatsLindh Avatar answered Dec 06 '25 23:12

MatsLindh