在索引中轮胎相当于Thinking_Sphinx属性

时间:2012-10-15 12:29:28

标签: tire

轮胎宝石中是否有类似于Thinking_Sphinx attributes中索引的属性(有)的内容 轮胎过滤器是否具有相同的用途?请帮我解决这个问题。

1 个答案:

答案 0 :(得分:0)

我对Thinking Sphinx并不是特别熟悉,但是......

点击这里:

https://github.com/karmi/tire

class Article < ActiveRecord::Base
  # ...

  def to_indexed_json
    names      = author.split(/\W/)
    last_name  = names.pop
    first_name = names.join

    {
      :title   => title,
      :content => content,
      :author  => {
        :first_name => first_name,
        :last_name  => last_name
      }
    }.to_json
  end
end

在索引中提供自定义定义允许您在您发送的链接中使用:as功能。

为了过滤,您需要添加过滤器,然后通过构面应用它。