Commit 690d93e284a2bf605320af2138a0c6dfb8c11fac
1 parent
e20ac496
Exists in
master
and in
15 other branches
Added request parameters to curl representation - closes #1346
Showing
3 changed files
with
9 additions
and
2 deletions
Show diff stats
CHANGELOG.md
lib/searchkick/logging.rb
... | ... | @@ -164,11 +164,14 @@ module Searchkick |
164 | 164 | name = "#{payload[:name]} (#{event.duration.round(1)}ms)" |
165 | 165 | type = payload[:query][:type] |
166 | 166 | index = payload[:query][:index].is_a?(Array) ? payload[:query][:index].join(",") : payload[:query][:index] |
167 | + request_params = payload[:query].except(:index, :type, :body) | |
167 | 168 | |
168 | 169 | # no easy way to tell which host the client will use |
169 | 170 | host = Searchkick.client.transport.hosts.first |
170 | 171 | params = ["pretty"] |
171 | - params << "scroll=#{payload[:query][:scroll]}" if payload[:query][:scroll] | |
172 | + request_params.each do |k, v| | |
173 | + params << "#{CGI.escape(k.to_s)}=#{CGI.escape(v.to_s)}" | |
174 | + end | |
172 | 175 | debug " #{color(name, YELLOW, true)} curl #{host[:protocol]}://#{host[:host]}:#{host[:port]}/#{CGI.escape(index)}#{type ? "/#{type.map { |t| CGI.escape(t) }.join(',')}" : ''}/_search?#{params.join('&')} -H 'Content-Type: application/json' -d '#{payload[:query][:body].to_json}'" |
173 | 176 | end |
174 | 177 | ... | ... |
lib/searchkick/query.rb
... | ... | @@ -106,12 +106,15 @@ module Searchkick |
106 | 106 | query = params |
107 | 107 | type = query[:type] |
108 | 108 | index = query[:index].is_a?(Array) ? query[:index].join(",") : query[:index] |
109 | + request_params = query.except(:index, :type, :body) | |
109 | 110 | |
110 | 111 | # no easy way to tell which host the client will use |
111 | 112 | host = Searchkick.client.transport.hosts.first |
112 | 113 | credentials = host[:user] || host[:password] ? "#{host[:user]}:#{host[:password]}@" : nil |
113 | 114 | params = ["pretty"] |
114 | - params << "scroll=#{options[:scroll]}" if options[:scroll] | |
115 | + request_params.each do |k, v| | |
116 | + params << "#{CGI.escape(k.to_s)}=#{CGI.escape(v.to_s)}" | |
117 | + end | |
115 | 118 | "curl #{host[:protocol]}://#{credentials}#{host[:host]}:#{host[:port]}/#{CGI.escape(index)}#{type ? "/#{type.map { |t| CGI.escape(t) }.join(',')}" : ''}/_search?#{params.join('&')} -H 'Content-Type: application/json' -d '#{query[:body].to_json}'" |
116 | 119 | end |
117 | 120 | ... | ... |