Reputation: 830
I am trying to implement case-insensitive search to my title
and content
fields, however to no avail. I have tried the following methods:
Adding <filter class="solr.LowerCaseFilterFactory" />
to 'text_general
' field type in schema.xml / managed-schema.xml
, to both 'index' and 'analyze' tokenizers.
My title and content field each will be of 'text_general
' type.
I tried searching the following:
*abc*
: No results of 'ABC' appears*ABC*
: Only results with 'ABC' appears.This clearly shows that lowercase filters are not working. Also pasted below is the debug results of the first query.
Also below is the screenshot of the title field when analyzing a sample text. Output seems ok, but search does not work as per expected. Is this a search query issue?
Thanks for any help in advanced!
Upvotes: 0
Views: 699
Reputation: 52802
No, it doesn't clearly show that the lowercase filtering doesn't work - what you're experiencing is that most filters or tokenizers aren't applied when you're doing a wildcard search (since they really can't be applied cleanly for a wildcard search where they don't have the whole term to work with).
The solution is, if you want to perform a wildcarded, lowercased search, is to perform the lowercasing or processing of the field before actually indexing it, and using only a tokenizer to split the text as necessary (where LowercaseTokenizer
seems to be the only one that is a MultiTermAwareComponent). Otherwise, if you don't want to perform any tokenization or splitting of the string, use a string
field.
You can do this either in your own code that sends content to Solr or in an update processor.
Upvotes: 0