Skip to content

Instantly share code, notes, and snippets.

@bensie
Created December 12, 2012 17:35
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 bensie/4269859 to your computer and use it in GitHub Desktop.
Save bensie/4269859 to your computer and use it in GitHub Desktop.
"products" : {
"product" : {
"properties" : {
"id" : {
"type" : "string",
"index" : "not_analyzed"
},
"product_name" : {
"type" : "string",
"analyzer" : "keyword"
}
}
}
}
{"query":{"bool":{"must":[{"query_string":{"query":"1233","default_operator":"AND"}}]}},"sort":[{"id":"desc"}],"size":5}
def self.search(params, options = {})
tire.search(page: params[:page], per_page: 30) do
query do
boolean do
must { string params[:q], default_operator: "AND" } if params[:q].present?
end
end
sort { by :id, 'desc' }
size options[:size] if options[:size].present?
# raise to_json
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment