thebernardlim
thebernardlim

Reputation: 830

Solr lowercase doesnt work

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.

enter image description here

My title and content field each will be of 'text_general' type. enter image description here

I tried searching the following:

This clearly shows that lowercase filters are not working. Also pasted below is the debug results of the first query.

enter image description here

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?

enter image description here

Thanks for any help in advanced!

Upvotes: 0

Views: 699

Answers (1)

MatsLindh
MatsLindh

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

Related Questions