Commit 0c71b0c7e184586d1fbb742f4fa674ba3a186608

Authored by Andrew Kane
1 parent 19790c64

Removed curl from search notifications to prevent confusion

CHANGELOG.md
... ... @@ -3,7 +3,7 @@
3 3 - Added safety check for multiple `Model.reindex`
4 4 - Added `deep_paging` option
5 5 - Added request parameters to `curl` representation
6   -- Cleaned up search notifications
  6 +- Removed curl from search notifications to prevent confusion
7 7  
8 8 ## 4.1.1 (2019-11-19)
9 9  
... ...
lib/searchkick/logging.rb
... ... @@ -7,8 +7,7 @@ module Searchkick
7 7 name = searchkick_klass ? "#{searchkick_klass.name} Search" : "Search"
8 8 event = {
9 9 name: name,
10   - query: params,
11   - term: original_term
  10 + query: params
12 11 }
13 12 ActiveSupport::Notifications.instrument("search.searchkick", event) do
14 13 super
... ... @@ -134,7 +133,6 @@ module Searchkick
134 133 event = {
135 134 name: "Multi Search",
136 135 body: searches.flat_map { |q| [q.params.except(:body).to_json, q.body.to_json] }.map { |v| "#{v}\n" }.join,
137   - terms: searches.map { |q| q.original_term }
138 136 }
139 137 ActiveSupport::Notifications.instrument("multi_search.searchkick", event) do
140 138 super
... ... @@ -164,10 +162,17 @@ module Searchkick
164 162  
165 163 payload = event.payload
166 164 name = "#{payload[:name]} (#{event.duration.round(1)}ms)"
167   - message = {}
168   - message[:query] = payload[:term] || "[custom]"
169 165  
170   - debug " #{color(name, YELLOW, true)} #{message.to_json}"
  166 + index = payload[:query][:index].is_a?(Array) ? payload[:query][:index].join(",") : payload[:query][:index]
  167 + type = payload[:query][:type]
  168 + request_params = payload[:query].except(:index, :type, :body)
  169 +
  170 + params = []
  171 + request_params.each do |k, v|
  172 + params << "#{CGI.escape(k.to_s)}=#{CGI.escape(v.to_s)}"
  173 + end
  174 +
  175 + debug " #{color(name, YELLOW, true)} #{index}#{type ? "/#{type.map { |t| CGI.escape(t) }.join(',')}" : ''}/_search#{params.any? ? "?" + params.join('&') : nil} #{payload[:query][:body].to_json}"
171 176 end
172 177  
173 178 def request(event)
... ... @@ -186,10 +191,8 @@ module Searchkick
186 191  
187 192 payload = event.payload
188 193 name = "#{payload[:name]} (#{event.duration.round(1)}ms)"
189   - message = {}
190   - message[:queries] = payload[:terms].map { |q| q || "[custom]" }
191 194  
192   - debug " #{color(name, YELLOW, true)} #{message.to_json}"
  195 + debug " #{color(name, YELLOW, true)} _msearch #{payload[:body]}"
193 196 end
194 197 end
195 198  
... ...
lib/searchkick/query.rb
... ... @@ -4,7 +4,7 @@ module Searchkick
4 4  
5 5 @@metric_aggs = [:avg, :cardinality, :max, :min, :sum]
6 6  
7   - attr_reader :klass, :term, :options, :original_term
  7 + attr_reader :klass, :term, :options
8 8 attr_accessor :body
9 9  
10 10 def_delegators :execute, :map, :each, :any?, :empty?, :size, :length, :slice, :[], :to_ary,
... ... @@ -23,7 +23,6 @@ module Searchkick
23 23 raise ArgumentError, "unknown keywords: #{unknown_keywords.join(", ")}" if unknown_keywords.any?
24 24  
25 25 term = term.to_s
26   - @original_term = options[:body] ? nil : term
27 26  
28 27 if options[:emoji]
29 28 term = EmojiParser.parse_unicode(term) { |e| " #{e.name} " }.strip
... ...