为什么过滤器不适用于 Lucene.Net 中的文本/字符串值?

1

本文介绍了为什么过滤器不适用于 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 中的文本/字符串值?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

The End

相关推荐

C# 中的多播委托奇怪行为?
Multicast delegate weird behavior in C#?(C# 中的多播委托奇怪行为?)...
2023-11-11 C#/.NET开发问题
6

参数计数与调用不匹配?
Parameter count mismatch with Invoke?(参数计数与调用不匹配?)...
2023-11-11 C#/.NET开发问题
26

如何将代表存储在列表中
How to store delegates in a List(如何将代表存储在列表中)...
2023-11-11 C#/.NET开发问题
6

代表如何工作(在后台)?
How delegates work (in the background)?(代表如何工作(在后台)?)...
2023-11-11 C#/.NET开发问题
5

没有 EndInvoke 的 C# 异步调用?
C# Asynchronous call without EndInvoke?(没有 EndInvoke 的 C# 异步调用?)...
2023-11-11 C#/.NET开发问题
2

Delegate.CreateDelegate() 和泛型:错误绑定到目标方法
Delegate.CreateDelegate() and generics: Error binding to target method(Delegate.CreateDelegate() 和泛型:错误绑定到目标方法)...
2023-11-11 C#/.NET开发问题
14