Why is filter not working with text/string values in Lucene.Net?

不问归期 提交于 2019-11-27 08:39:46

问题


I have made a filter in Lucene.Net to limit the result of the search. I am encountering a very strange issue. The filter is not working with Text Values but working with number values.

For Example:

If I am making a filter with Number values something like below. It is working perfectly.

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);

it is failing. The result is not displaying any records.

Can somebody explain me the issue. Also, I have tested it numerous times to make this claim. I have read on some forums that the Term Query in Lucene versions below 3 will probably have this issue. However, I have changed the version to 3.0.3 but error still persists. I badly need the filter in my program to work. Otherwise I will have to move away from Lucene and find something else.


回答1:


StandardAnalyzer will lowercase all the characters in your TokenStream.

Try this:

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


来源:https://stackoverflow.com/questions/16906689/why-is-filter-not-working-with-text-string-values-in-lucene-net

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!