Reputation: 550
I am using solr for searching. When i search a word contains uppercase letters from
description, its not showing any result. But it gives result for lowercase letters ..
Eg: If my query is q=description:* stack * , i will get the result . But if query is
q=description:* Stack * , it wont give any result evenif description contains that word
My schema contains :
<fieldType name="string" class="solr.TextField">
<analyzer type="index">
<tokenizer class="solr.KeywordTokenizerFactory"/>
<filter class="solr.ASCIIFoldingFilterFactory"/>
<filter class="solr.LowerCaseFilterFactory" />
<filter class="solr.ReversedWildcardFilterFactory" />
</analyzer>
<analyzer type="query">
<tokenizer class="solr.KeywordTokenizerFactory"/>
<filter class="solr.ASCIIFoldingFilterFactory"/>
<filter class="solr.LowerCaseFilterFactory" />
<filter class="solr.ReversedWildcardFilterFactory" />
</analyzer>
</fieldType>
I want to search with upper case letters also..
Can someone help me ?
Upvotes: 2
Views: 1286
Reputation: 60205
Have a look at the Solr wiki. It says:
Add this filter to the index analyzer, but not the query analyzer.
Try querying with debugQuery=on
after you've changed the schema to reflect the wiki instructions:
<str name="querystring">text:*Stack*</str>
<str name="parsedquery">text:#1;*kcatS*</str>
As you can see, the ReversedWildcardFilterFactory
changes your query even if it's not in your query analyzer chain, with a fieldType like this:
<fieldType name="text" class="solr.TextField">
<analyzer type="index">
<tokenizer class="solr.KeywordTokenizerFactory"/>
<filter class="solr.ASCIIFoldingFilterFactory"/>
<filter class="solr.LowerCaseFilterFactory"/>
<filter class="solr.ReversedWildcardFilterFactory" />
</analyzer>
<analyzer type="query">
<tokenizer class="solr.KeywordTokenizerFactory"/>
<filter class="solr.ASCIIFoldingFilterFactory"/>
<filter class="solr.LowerCaseFilterFactory"/>
</analyzer>
</fieldType>
Furthermore, the LowerCaseFilterFactory
is not fired for your query (the S
is not lowercase in the parsed query). The same happens for ASCIIFoldingFilterFactory
.
Have a look here to know more:
Solr does not analyze queries in which there are wildcards. Yes, this means that the filter LowerCaseFilterFactory, during indexing, turns Stack to stack but when making queries this is not happening, despite the fact that the filters are defined correctly. And that is why you don't get any search results.
The easiest solution that comes in my mind is making your queries lowercase on client side, before sending them to Solr. You should also consider that the ASCIIFoldingFilterFactory
is not fired either. Do you really need it?
Upvotes: 1