Solr 建议器教程/Java 简单示例

发布于 2024-11-05 10:19:33 字数 827 浏览 3 评论 0原文

我看到一些关于如何在 Solr 中使用 Suggester 执行特定操作的问题,但如何实际使用它呢?我被困在如何简单地查询建议 api 以获取 Java 中的结果,也许使用 Solrj?我只是找不到任何简单的教程来解释它。

我所拥有的只是 SuggesterTest 类,即使在尝试解码 3 小时后我仍然无法理解事情是如何工作的,尤其是看起来像这样的疯狂请求:

req("qt", requestUri, "q", "ac", SpellingParams.SPELLCHECK_COUNT, "2", SpellingParams.SPELLCHECK_ONLY_MORE_POPULAR, "true"),
            "//lst[@name='spellcheck']/lst[@name='suggestions']/lst[@name='ac']/int[@name='numFound'][.='2']",
            "//lst[@name='spellcheck']/lst[@name='suggestions']/lst[@name='ac']/arr[@name='suggestion']/str[1][.='acquire']",
            "//lst[@name='spellcheck']/lst[@name='suggestions']/lst[@name='ac']/arr[@name='suggestion']/str[2][.='accommodate']"

难道没有比这更简单的东西了吗?

另外,还有一个问题,我需要重建建议索引吗?如果假设我之前添加了一些数据,现在想将它们与建议器一起使用。我是否还需要在建议中指定要查询的字段?

谢谢!

I see some question about how to do specific things with Suggester in Solr, but how about how to actually use it? I'm stuck in how to simply query the suggest api to get the results in Java, maybe using Solrj? I just cannot find any simple tutorial that would explain it.

All I have is the SuggesterTest class that even after 3hours of trying to decode I still cannot understand how things work, especially the crazy requests that look like:

req("qt", requestUri, "q", "ac", SpellingParams.SPELLCHECK_COUNT, "2", SpellingParams.SPELLCHECK_ONLY_MORE_POPULAR, "true"),
            "//lst[@name='spellcheck']/lst[@name='suggestions']/lst[@name='ac']/int[@name='numFound'][.='2']",
            "//lst[@name='spellcheck']/lst[@name='suggestions']/lst[@name='ac']/arr[@name='suggestion']/str[1][.='acquire']",
            "//lst[@name='spellcheck']/lst[@name='suggestions']/lst[@name='ac']/arr[@name='suggestion']/str[2][.='accommodate']"

Isn't there anything simpler than this?

Also, another question, do I need to rebuild the index for the suggestions? if let's say I added some data before, and now want to use them with suggester. Do I also need to specify somewhere which field I want to query in suggestions?

Thanks!

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

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

发布评论

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