ruby-on-rails - Thinking Sphinx 索引方法之间的区别

标签 ruby-on-rails thinking-sphinx

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

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

谢谢。

最佳答案

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

indexes 用于指定字段 - 根据 Thinking Sphinx 网站:

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 用于指定属性 - 同样,根据 Thinking Sphinx 网站:

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.

关于ruby-on-rails - Thinking Sphinx 索引方法之间的区别,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/4698573/

相关文章:

ruby-on-rails - 为什么即使我删除了 application.js 文件,Capybara + Rspec 测试仍然通过?

javascript - Rails 编译的 javascript 资源调试

javascript - 如何在 Rails 中处理特定于环境的 javascript 文件?

ruby-on-rails - acts_as_tree 不会破坏模型的 child

Mysql2::错误:操作数应包含 1 列:

ruby-on-rails - 如何在 Thinking Sphinx 中一起使用多值属性 (MVA) 和方面?

ruby - Thinking_Sphinx 搜索选项

ruby-on-rails - 使用 Thinking Sphinx 时,Delta 索引无法在服务器上运行

ruby-on-rails - Thinking Sphinx——在配置文件中找不到索引

ruby-on-rails - 思考 sphinx 不索引新添加的记录