summaryrefslogtreecommitdiff
path: root/lib/chef/search/query.rb
diff options
context:
space:
mode:
Diffstat (limited to 'lib/chef/search/query.rb')
-rw-r--r--lib/chef/search/query.rb10
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)