简体   繁体   English

轮胎上Elasticsearch的精确词组匹配

[英]Exact phrase match in elasticsearch on tire

I am implementing elasticsearch on tire in my ruby on rails application. 我正在我的ruby on rails应用程序中对轮胎实施Elasticsearch
I am doing pretty good so far with it. 到目前为止,我做的还不错。 Now I want to retrieve results that matches exact values. 现在,我想检索与精确值匹配的结果。
eg If there are two records with title "once upon" and "once upon a time", "title: once upon" should return only one with title exactly "once upon" 例如,如果有两个记录的标题为“ once on”和“ once on time”,则“ title:Onceong”应仅返回标题为“ once on”的记录

Here is example code: 这是示例代码:

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

Hope it will helpful! 希望对您有所帮助!

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM