自动完成的简单 Solr 模式问题

发布于 2024-09-25 00:27:16 字数 864 浏览 0 评论 0原文

我有一个非常简单的 SQL 表,我想将其导入到 Solr 中,但由于我想要搜索的功能,我无法确定最佳模式。

用户将开始在输入框中键入内容,在 3 个字符后,它将向服务器发送请求并提取最相关的结果,返回前 15 个匹配的 ID 和名称。

表 ex)

id | name
----------------
1 | boating magazines
2 | boats weekly
3 | boaters collection
4 | shipping lane
5 | ships today

搜索和预期返回 ex)

boa | [1, boating magazines], [2, boaters weekly], [3, boaters collection] 
boat | [1, boating magazines], [2, boaters weekly], [3, boaters collection], [4, shipping lane], [5, ships today]
shi | [4, shipping lane], [5, ships today]
ship | [1, boating magazines], [2, boaters weekly], [3, boaters collection], [4, shipping lane], [5, ships today]
boating | [1, boating magazines], [2, boaters weekly], [3, boaters collection], [4, shipping lane], [5, ships today]

(显然这些将作为 xml 返回)有关

我如何实现此目的的任何信息将不胜感激。谢谢。

I have a very simple SQL table that I want to import into Solr but because of the features I want for search I can't determine the best schema.

The user will start typing into an input box and after 3 characters it will send the request to the server and pull out the most relevant results returning the top 15 matching id and name.

Table ex)

id | name
----------------
1 | boating magazines
2 | boats weekly
3 | boaters collection
4 | shipping lane
5 | ships today

Search and expected return ex)

boa | [1, boating magazines], [2, boaters weekly], [3, boaters collection] 
boat | [1, boating magazines], [2, boaters weekly], [3, boaters collection], [4, shipping lane], [5, ships today]
shi | [4, shipping lane], [5, ships today]
ship | [1, boating magazines], [2, boaters weekly], [3, boaters collection], [4, shipping lane], [5, ships today]
boating | [1, boating magazines], [2, boaters weekly], [3, boaters collection], [4, shipping lane], [5, ships today]

(obviously those would be returned as xml)

Any info on how I would achieve this would be appreciated. Thanks.

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

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

发布评论

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

评论(2

随梦而飞# 2024-10-02 00:27:16

您可以使用 facet.prefixTermsComponent 或 < a href="http://www.lucidimagination.com/blog/2009/09/08/auto-suggest-from-popular-queries-using-edgengrams/" rel="nofollow noreferrer">NGrams。

其中一篇文章还展示了如何使用 jQuery 绑定它,或者您可以 使用ajax-solr

顺便说一下,下一个版本中将包含一个特定的自动建议组件 Solr 的。

You can implement this using either facet.prefix, TermsComponent or NGrams.

One of those articles also shows how to bind it using jQuery or you could use ajax-solr.

By the way, a specific autosuggest component is to be included in the next release of Solr.

怪我鬧 2024-10-02 00:27:16

你到底想知道什么?

如果您的问题是如何在那里获取数据?最简单的方法是发布 xml 文件......

你如何定义你的 schema.xml?你不必这样做,有预定义的字符串通配符字段,我认为它们以 _s 结尾。

你如何形成查询?...就像 myfield_string:"boa*"

显然是 xml 一样简单?为什么? json 更小,但同样适合此目的!

你看过官方教程吗? http://lucene.apache.org/solr/tutorial.html

你想要吗对单词或整个文档进行自动提示?

首先很容易。 solr 甚至有其非常优化的处理程序。查看本教程: http:// www.mattweber.org/2009/05/02/solr-autosuggest-with-termscomponent-and-jquery/

第二个变得更有趣。如果有人输入“船只集合”或类似的内容怎么办?我个人建议使用 dismax 处理程序并在末尾使用通配符进行自动建议。那么单词是逻辑或连词,未完成的单词在开头匹配......

what do you want to know exactly?

if your question is how to get your data there? easiest way is posting xml files....

how do you define your schema.xml? you dont have to, there are pre-defined wildcard fields for strings, they end with _s i think.

how do you form the query?... well as easy as myfield_string:"boa*"

obviously xml? why? json is smaller and just as good for this purpose!

have you checked out the official tutorial? http://lucene.apache.org/solr/tutorial.html

do you want to do an autosuggesting for words or whole documents?

first is very easy. solr even has its very optimized handler for that. check out this tutorial: http://www.mattweber.org/2009/05/02/solr-autosuggest-with-termscomponent-and-jquery/

second one gets more interesting. what if someone types "collection of boats" or something like that? i personally would recommend using dismax handler with a wildcard at the end for autosuggesting. then words are in logical OR conjunction and the not finished word is matched at the beginning...

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