Thinking Sphinx 索引方法之间的差异

发布于 2024-10-12 17:30:15 字数 191 浏览 1 评论 0原文

想知道它们之间有什么区别:

indexes shop.created_at, :as =>created_at
has shop(:created_at), :as => :created_at
has shop.created_at, :as => :created_at

谢谢。

Wondering what is the difference between these:

indexes shop.created_at, :as =>created_at
has shop(:created_at), :as => :created_at
has shop.created_at, :as => :created_at

Thanks.

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

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

发布评论

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

评论(1

北音执念 2024-10-19 17:30:15

所以我认为第二个和第三个之间没有区别(如果我错了,请纠正我!)但是,我确信第一个和第二个

索引之间的区别用于指定字段 -根据 Thinking Sphinx 网站:

字段是搜索查询的内容 - 因此,如果您希望将单词与特定文档相关联,最好确保它们位于索引中的字段中。它们只是字符串数据——您的字段中可以有数字和日期等,但 Sphinx 只会将它们视为字符串,而不是其他。

has 用于指定属性 - 同样,根据 Thinking Sphinx 网站:

属性用于对搜索结果进行排序、过滤和分组。不过,Sphinx 的搜索词不会对它们的值给予任何关注,并且它们仅限于以下数据类型:整数、浮点数、日期时间(作为 Unix 时间戳——因此无论如何都是整数)、布尔值和字符串。请注意,字符串属性会转换为序数整数,这对于排序特别有用,但除此之外就没有什么用了。

So I dont think there is a difference between the 2nd and 3rd (correct me if I am wrong!) however, I am sure of the difference between the 1st and 2nd

indexes is used to specify a field - according to the Thinking Sphinx website:

Fields are the content for your search queries – so if you want words tied to a specific document, you better make sure they’re in a field in your index. They are only string data – you could have numbers and dates and such in your fields, but Sphinx will only treat them as strings, nothing else.

has is used to specify an attribute - again, according to the Thinking Sphinx website:

Attributes are used for sorting, filtering and grouping your search results. Their values do not get paid any attention by Sphinx for search terms, though, and they’re limited to the following data types: integers, floats, datetimes (as Unix timestamps – and thus integers anyway), booleans, and strings. Take note that string attributes are converted to ordinal integers, which is especially useful for sorting, but not much else.

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