Commit c2922b9f14d19b3e29b2e8f0d0fe8cfeccc20336

Authored by Andrew
1 parent a6870254

Fixed linter errors [skip ci]

lib/searchkick/index_options.rb
@@ -4,8 +4,8 @@ module Searchkick @@ -4,8 +4,8 @@ module Searchkick
4 options = @options 4 options = @options
5 language = options[:language] 5 language = options[:language]
6 language = language.call if language.respond_to?(:call) 6 language = language.call if language.respond_to?(:call)
7 - type = options[:_type]  
8 - type = type.call if type.respond_to?(:call) 7 + index_type = options[:_type]
  8 + index_type = index_type.call if index_type.respond_to?(:call)
9 9
10 if options[:mappings] && !options[:merge_mappings] 10 if options[:mappings] && !options[:merge_mappings]
11 settings = options[:settings] || {} 11 settings = options[:settings] || {}
@@ -163,7 +163,7 @@ module Searchkick @@ -163,7 +163,7 @@ module Searchkick
163 settings[:analysis][:filter][:searchkick_synonym] = { 163 settings[:analysis][:filter][:searchkick_synonym] = {
164 type: "synonym", 164 type: "synonym",
165 # only remove a single space from synonyms so three-word synonyms will fail noisily instead of silently 165 # only remove a single space from synonyms so three-word synonyms will fail noisily instead of silently
166 - synonyms: synonyms.select { |s| s.size > 1 }.map { |s| s.is_a?(Array) ? s.map { |s| s.sub(/\s+/, "") }.join(",") : s }.map(&:downcase) 166 + synonyms: synonyms.select { |s| s.size > 1 }.map { |s| s.is_a?(Array) ? s.map { |s2| s2.sub(/\s+/, "") }.join(",") : s }.map(&:downcase)
167 } 167 }
168 # choosing a place for the synonym filter when stemming is not easy 168 # choosing a place for the synonym filter when stemming is not easy
169 # https://groups.google.com/forum/#!topic/elasticsearch/p7qcQlgHdB8 169 # https://groups.google.com/forum/#!topic/elasticsearch/p7qcQlgHdB8
@@ -308,7 +308,7 @@ module Searchkick @@ -308,7 +308,7 @@ module Searchkick
308 multi_field = dynamic_fields["{name}"].merge(fields: dynamic_fields.except("{name}")) 308 multi_field = dynamic_fields["{name}"].merge(fields: dynamic_fields.except("{name}"))
309 309
310 mappings = { 310 mappings = {
311 - type => { 311 + index_type => {
312 properties: mapping, 312 properties: mapping,
313 _routing: routing, 313 _routing: routing,
314 # https://gist.github.com/kimchy/2898285 314 # https://gist.github.com/kimchy/2898285
lib/searchkick/query.rb
@@ -135,7 +135,7 @@ module Searchkick @@ -135,7 +135,7 @@ module Searchkick
135 if searchkick_index 135 if searchkick_index
136 puts "Model Search Data" 136 puts "Model Search Data"
137 begin 137 begin
138 - pp klass.first(3).map { |r| {index: searchkick_index.record_data(r).merge(data: searchkick_index.send(:search_data, r))}} 138 + pp(klass.first(3).map { |r| {index: searchkick_index.record_data(r).merge(data: searchkick_index.send(:search_data, r))}})
139 rescue => e 139 rescue => e
140 puts "#{e.class.name}: #{e.message}" 140 puts "#{e.class.name}: #{e.message}"
141 end 141 end
@@ -331,7 +331,7 @@ module Searchkick @@ -331,7 +331,7 @@ module Searchkick
331 end 331 end
332 332
333 if misspellings != false && match_type == :match 333 if misspellings != false && match_type == :match
334 - qs.concat qs.map { |q| q.except(:cutoff_frequency).merge(fuzziness: edit_distance, prefix_length: prefix_length, max_expansions: max_expansions, boost: factor).merge(transpositions) } 334 + qs.concat(qs.map { |q| q.except(:cutoff_frequency).merge(fuzziness: edit_distance, prefix_length: prefix_length, max_expansions: max_expansions, boost: factor).merge(transpositions) })
335 end 335 end
336 336
337 if field.start_with?("*.") 337 if field.start_with?("*.")
@@ -706,7 +706,7 @@ module Searchkick @@ -706,7 +706,7 @@ module Searchkick
706 ranges: agg_options[:date_ranges] 706 ranges: agg_options[:date_ranges]
707 }.merge(shared_agg_options) 707 }.merge(shared_agg_options)
708 } 708 }
709 - elsif histogram = agg_options[:date_histogram] 709 + elsif (histogram = agg_options[:date_histogram])
710 interval = histogram[:interval] 710 interval = histogram[:interval]
711 payload[:aggs][field] = { 711 payload[:aggs][field] = {
712 date_histogram: { 712 date_histogram: {
@@ -714,7 +714,7 @@ module Searchkick @@ -714,7 +714,7 @@ module Searchkick
714 interval: interval 714 interval: interval
715 } 715 }
716 } 716 }
717 - elsif metric = @@metric_aggs.find { |k| agg_options.has_key?(k) } 717 + elsif (metric = @@metric_aggs.find { |k| agg_options.has_key?(k) })
718 payload[:aggs][field] = { 718 payload[:aggs][field] = {
719 metric => { 719 metric => {
720 field: agg_options[metric][:field] || field 720 field: agg_options[metric][:field] || field
lib/searchkick/reindex_queue.rb
@@ -15,7 +15,7 @@ module Searchkick @@ -15,7 +15,7 @@ module Searchkick
15 # TODO use reliable queuing 15 # TODO use reliable queuing
16 def reserve(limit: 1000) 16 def reserve(limit: 1000)
17 record_ids = Set.new 17 record_ids = Set.new
18 - while record_ids.size < limit && record_id = Searchkick.with_redis { |r| r.rpop(redis_key) } 18 + while record_ids.size < limit && (record_id = Searchkick.with_redis { |r| r.rpop(redis_key) })
19 record_ids << record_id 19 record_ids << record_id
20 end 20 end
21 record_ids.to_a 21 record_ids.to_a