0

I'm having trouble converting the following valid JSON query to elastic search into the ruby gem 'tire' equivalent. Any help is greatly appriciated...


{ 
    "query" : {
        "term" : { "_all" : "coffee" }
    },
    "filter" : {
        "or" : [
            {
                "term" : { "email_store" : true }
            },
            {
                "term" : { "phone_store" : false }
            }
        ]
    }
}
javanna
  • 59,145
  • 14
  • 144
  • 125
Kirk
  • 1,521
  • 14
  • 20

1 Answers1

1

This would be the equivalent notation in Tire 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

Have a look at https://github.com/karmi/tire/blob/master/test/integration/filters_test.rb#L25-29.

karmi
  • 14,059
  • 3
  • 33
  • 41