搜索词开头的通配符 -Lucene

发布于 2024-09-13 03:29:53 字数 417 浏览 1 评论 0原文

据我所知 lucene(.net) 不支持搜索词开头的通配符 --> http://lucene.apache.org/java/2_0_0/queryparsersyntax.html “注意:您不能使用 * 或 ? 符号作为搜索的第一个字符。”

例如 *myword

也许是因为在搜索词之前搜索“所有内容”非常困难。

尽管如此,我们还是在寻找一种在一开始就使用通配符的方法。 有谁知道这是否可能?

一个想法是 asearchterm、bsearchterm、...z*searchterm ...但这对我来说似乎有点随机。

提前致谢

As far as i know lucene(.net) doesn't support the wildcard at the beginning of a searchterm
--> http://lucene.apache.org/java/2_0_0/queryparsersyntax.html
"Note: You cannot use a * or ? symbol as the first character of a search."

for example
*myword

maybe because it's quiet difficult to search "everything" before the searchterm.

Despite that, We are looknig for a way to use the wildcard at the beginning.
Does anyone know if this is possible?

One Thought was asearchterm, bsearchterm, ....z*searchterm
... but that seems a bit random to me.

thanks in advance

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

你是年少的欢喜 2024-09-20 03:29:53

您的问题被标记为 Lucene.NET,所以我假设您指的是 .NET 版本而不是 Java 版本。

是的,您可以在搜索词的开头使用 via 通配符,

var queryParser = new QueryParser(LuceneVersion, "content", new StandardAnalyzer(LuceneVersion));
queryParser.SetAllowLeadingWildcard(true);

但您需要注意性能后果。在此博客中查找更详细的源代码。

由于 Lucene.NET 是 Java 版本的移植,我怀疑您可以对 Java 版本使用相同的方法。不过我没有验证这一点。

Your question is tagged with Lucene.NET so I assume you mean the .NET version rather than the Java version.

Yes, you can have wildcards at the beginning of a search term by via

var queryParser = new QueryParser(LuceneVersion, "content", new StandardAnalyzer(LuceneVersion));
queryParser.SetAllowLeadingWildcard(true);

but you need to be aware of the performance consequences. Find more detailed source code in this blog.

Since Lucene.NET is a port of the Java version, I suspect you could use the same approach for the Java version. I didn't verify this, though.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文