From 8261791ced25227781f0d0ad3f44ef77c889d53b Mon Sep 17 00:00:00 2001 From: Claire McQuin Date: Fri, 19 Dec 2014 12:45:51 -0800 Subject: Build configurable search string. --- lib/chef/search/query.rb | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) (limited to 'lib/chef/search/query.rb') 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) -- cgit v1.2.1