Ravi
Ravi

Reputation: 873

Solr Query Single character

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>

Upvotes: 3

Views: 2273

Answers (2)

Christian Lendel
Christian Lendel

Reputation: 420

First of all I would suggest you build up a query like this: (well lets call your field which contains your single characters TEST for this example)

Query = TEST:p AND TEST:a

Do you get any results?

Upvotes: 0

MatsLindh
MatsLindh

Reputation: 52892

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.

Upvotes: 3

Related Questions