复杂短语查询解析器

发布于 2024-10-24 20:36:47 字数 803 浏览 4 评论 0原文

我想使用 Hibernate Search 为我的网站实现模糊短语搜索。我从一些人那里读到,ComplexPhraseQueryParser 可以解决这个问题。

但问题是我有一些误解或与之相关的问题。

例如,让我们考虑这样一个测试标题(我有很多这样的标题,我需要让用户搜索他们喜欢的任何内容):

“你知道如何保持身材吗?”

如果有人会输入 “你知道如何保持身材吗?”我的 ComplexPhraseQueryParser 将找不到任何内容。但是,如果我在拼写错误的单词(如“cnow~”)后面放置一个“~”字符,它将起作用并返回结果。

这是什么原因呢? ComplexPhraseQueryParser 不支持这种情况吗?

我想让我的搜索处理一些拼写错误的单词并返回结果(类似于谷歌搜索)。

ComplexPhraseQueryParser quizTitlePhraseQuery = new ComplexPhraseQueryParser(Version.LUCENE_30, "title", new StandardAnalyzer(
                        Version.LUCENE_30)) ;
quizTitlePhraseQuery.setPhraseSlop(100);
                quizTitlePhraseQuery.setDefaultOperator(Operator.AND);
                quizTitlePhraseQuery.setFuzzyMinSim(0.1f);

先感谢您!

I would like to implement for my website a fuzzy phrase search using Hibernate Search. I've read from some people that ComplexPhraseQueryParser is ok for this.

But the thing is that I have some missunderstandings or issues related to it.

So for instance let's consider a test title like this (I have a lot of this and I need to let users search whatever they like):

"Do you know how to be in shape?"

If someone will type
"do you cnow how to be in shape?" my ComplexPhraseQueryParser will not find anyting. But if I put a "~" character after the misspeled word like "cnow~" it will work and return a result.

What is the reason of this? Doesn't ComplexPhraseQueryParser support such situations?

I would like to make my search deal with few misspelled words and return results (similar to google search).

ComplexPhraseQueryParser quizTitlePhraseQuery = new ComplexPhraseQueryParser(Version.LUCENE_30, "title", new StandardAnalyzer(
                        Version.LUCENE_30)) ;
quizTitlePhraseQuery.setPhraseSlop(100);
                quizTitlePhraseQuery.setDefaultOperator(Operator.AND);
                quizTitlePhraseQuery.setFuzzyMinSim(0.1f);

Thank you in advance!

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

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

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。
列表为空,暂无数据
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文