为什么不与Lucene.Net文本/字符串值过滤器的工作? [英] Why is filter not working with text/string values in Lucene.Net?

查看:150
本文介绍了为什么不与Lucene.Net文本/字符串值过滤器的工作?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已在Lucene.Net过滤器以限制搜索的结果。我遇到一个很奇怪的问题。该过滤器不与文本值工作,但与数值工作

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.

例如:

如果我制造过滤与数值类似下面。它可以正常使用。

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.

有人可以解释我的问题。另外,我还测试了无数次,使这一说法。我看过一些论坛的期限查询Lucene的版本低于3将可能有这个问题。不过,我已经改变了版本为3.0.3,但错误依然存在。我很喜欢我的程序工作的过滤器。否则,我将不得不从Lucene的移开,寻找别的东西。

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.

推荐答案

StandardAnalyzer 将小写的所有字符在的TokenStream

StandardAnalyzer will lowercase all the characters in your TokenStream.

试试这个:

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

这篇关于为什么不与Lucene.Net文本/字符串值过滤器的工作?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆