0

我在我的 ruby​​ on rails 应用程序中实现了对轮胎的弹性搜索。 到目前为止,我做得很好。现在我想检索与精确值匹配的结果。 例如,如果有两个标题为“once on”和“once on a time”的记录,“title: once on”应该只返回一个标题正好为“once on”的记录

4

1 回答 1

1

这是示例代码:

Tire.search 'articles', do |search|
    search.size 100        #  Limit record
    search.from 0          #  start offeset

    # search.query.text keyword, :type => :phrase
    search.query do |query|
        query.text :_all, keyword, :type => :phrase
    end
  end
end

希望它会有所帮助!

于 2012-03-20T03:27:22.397 回答