Created
December 12, 2012 17:35
-
-
Save bensie/4269859 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
"products" : { | |
"product" : { | |
"properties" : { | |
"id" : { | |
"type" : "string", | |
"index" : "not_analyzed" | |
}, | |
"product_name" : { | |
"type" : "string", | |
"analyzer" : "keyword" | |
} | |
} | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{"query":{"bool":{"must":[{"query_string":{"query":"1233","default_operator":"AND"}}]}},"sort":[{"id":"desc"}],"size":5} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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