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

查看:21
本文介绍了为什么过滤器不适用于 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);

但是,如果我给出一个包含 Text 的值

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 的 Term Query 可能会有这个问题.但是,我已将版本更改为 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天全站免登陆