简体   繁体   English

为什么在Lucene.Net中,过滤器无法处理文本/字符串值?

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

I have made a filter in Lucene.Net to limit the result of the search. 我在Lucene.Net中进行了筛选,以限制搜索结果。 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 但是,如果我给出一个包含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. 我已经在一些论坛上阅读到,Lucene 3以下版本的术语查询可能会出现此问题。 However, I have changed the version to 3.0.3 but error still persists. 但是,我将版本更改为3.0.3,但错误仍然存​​在。 I badly need the filter in my program to work. 我非常需要程序中的过滤器才能工作。 Otherwise I will have to move away from Lucene and find something else. 否则,我将不得不离开Lucene并找到其他东西。

StandardAnalyzer will lowercase all the characters in your TokenStream . StandardAnalyzer将小写TokenStream所有字符。

Try this: 尝试这个:

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

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM