Why doesn't the filter work with text / string values ​​in Lucene.Net?

I made a filter in Lucene.Net to limit the search result. I have a very strange problem. The filter does not work with text values, but it works with numbers.

Example:

If I create a filter with Number values ​​as shown below. It works great.

String field = "id"; Filter LE= new QueryWrapperFilter(new TermQuery( new Term(field, "1234567"))); indexSearcher.Search(QueryMaker(searchString, searchfields), LE, coll); 

However, if I give a value containing Text

 String field = "id"; Filter LE = new QueryWrapperFilter(new TermQuery(new Term(field, "ZZZOCB9X9Y"))); indexSearcher.Search(QueryMaker(searchString, searchfields), LE, coll); 

he fails. As a result, records are not displayed.

Can someone explain this problem to me. In addition, I have repeatedly tested it to make this expression. I read on some forums that there may be a problem with the Query term in versions of Lucene below 3. However, I changed the version to 3.0.3, but the error still persists. I really need a filter in my program to work. Otherwise, I will have to move away from Lutsen and find something else.

0
source share
1 answer

StandardAnalyzer will contain the lowercase letters of all characters in TokenStream .

Try the following:

 Filter LE = new QueryWrapperFilter(new TermQuery(new Term(field, "ZZZOCB9X9Y".ToLowerInvariant()))); 
+3
source

Source: https://habr.com/ru/post/1332747/


All Articles