【问题标题】:How to convert elastic search JSON to Tire compatible query如何将弹性搜索 JSON 转换为轮胎兼容查询
【发布时间】:2012-09-29 23:03:52
【问题描述】:

我在将以下有效 JSON 查询转换为弹性搜索到 ruby​​ gem 'tire' 等效项时遇到问题。非常感谢任何帮助...


{ 
    "query" : {
        "term" : { "_all" : "coffee" }
    },
    "filter" : {
        "or" : [
            {
                "term" : { "email_store" : true }
            },
            {
                "term" : { "phone_store" : false }
            }
        ]
    }
}

【问题讨论】:

    标签: elasticsearch tire


    【解决方案1】:

    这将是轮胎 DSL 中的等效符号:

    require 'tire'
    
    s = Tire.search('articles') do
      query do
        term :_all, 'coffee'
      end
    
      filter :or, { term: { email_store: true  } },
                  { term: { phone_store: false } }
    end
    
    puts s.to_json
    

    看看https://github.com/karmi/tire/blob/master/test/integration/filters_test.rb#L25-29

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2018-09-23
      • 1970-01-01
      • 1970-01-01
      • 2013-02-14
      • 2012-08-18
      • 1970-01-01
      相关资源
      最近更新 更多