Skip to content

Instantly share code, notes, and snippets.

@scalabilitysolved
Created April 13, 2014 18:25
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save scalabilitysolved/10595902 to your computer and use it in GitHub Desktop.
Save scalabilitysolved/10595902 to your computer and use it in GitHub Desktop.
require 'couchbase'
require 'elasticsearch'
require 'hashie'
couchbase = Couchbase.connect(:bucket => "users", :hostname => "localhost")
client = Elasticsearch::Client.new log: true
response = client.search index: 'users',
body: {
query: {
match: {origin: "GB"}
},
filter: {
bool: {
must: {
range: {
number_of_visits: {from: 10, to: 2000}
}
},
must_not: {
range: {
number_of_visits: {from: 61, to: 120}
}
}
}
}
}
mash_response = Hashie::Mash.new response
mash_response.hits.hits.each do |hit|
puts hit["_id"]
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment