Lucene case sensitive & insensitive search

后端 未结 2 868
说谎
说谎 2021-01-12 00:01

I have a Lucene index which is currently case sensitive. I want to add the option of having a case insensitive search as a fall-back. This means that result

2条回答
  •  情书的邮戳
    2021-01-12 00:07

    The Lucene search is case sensitive, it's just that all input is usually lower-cased upon passing through Queryparser , so it feels like it's case insensitive. In other words, don't lower-case your input before indexing, and don't lower-case your queries (i.e. pick an Analyzer that doesn't lower-case) keyword-analyzer for example.

    [setLowercaseExpandedTerms][1](boolean lowercaseExpandedTerms)
    

    you can index the terms using case sensitive analyzer and when u want case-insensitive query use a class which doesnot convert your terms to lowercase

    look at Wildcard, Prefix, and Fuzzy queries

提交回复
热议问题