diff options
author | Claire McQuin <claire@getchef.com> | 2014-12-19 12:45:51 -0800 |
---|---|---|
committer | Claire McQuin <claire@getchef.com> | 2014-12-19 12:45:51 -0800 |
commit | 8261791ced25227781f0d0ad3f44ef77c889d53b (patch) | |
tree | 8d53acd234d25cb559d61937a27757f9bf78f18a /lib/chef/search/query.rb | |
parent | fe8ca9ea64205288d3cc0fa2ea6b80c953f8ea4c (diff) | |
download | chef-8261791ced25227781f0d0ad3f44ef77c889d53b.tar.gz |
Build configurable search string.mcquin/bugfix/search-filtering
Diffstat (limited to 'lib/chef/search/query.rb')
-rw-r--r-- | lib/chef/search/query.rb | 10 |
1 files changed, 9 insertions, 1 deletions
diff --git a/lib/chef/search/query.rb b/lib/chef/search/query.rb index b68749f196..8656e810db 100644 --- a/lib/chef/search/query.rb +++ b/lib/chef/search/query.rb @@ -124,8 +124,16 @@ WARNDEP s && URI.escape(s.to_s) end + def create_query_string(type, query, rows, start, sort) + qstr = "search/#{type}?q=#{escape(query)}" + qstr += "&sort=#{escape(sort)}" if sort + qstr += "&start=#{escape(start)}" if start + qstr += "&rows=#{escape(rows)}" if rows + qstr + end + def call_rest_service(type, query:'*:*', rows:nil, start:0, sort:'X_CHEF_id_CHEF_X asc', filter_result:nil) - query_string = "search/#{type}?q=#{escape(query)}&sort=#{escape(sort)}&start=#{escape(start)}#{"&rows=" + escape(rows) if rows}" + query_string = create_query_string(type, query, rows, start, sort) if filter_result response = rest.post_rest(query_string, filter_result) |