diff --git a/lib/searchkick/index_options.rb b/lib/searchkick/index_options.rb index 0c2a783..622ae7f 100644 --- a/lib/searchkick/index_options.rb +++ b/lib/searchkick/index_options.rb @@ -4,8 +4,8 @@ module Searchkick options = @options language = options[:language] language = language.call if language.respond_to?(:call) - type = options[:_type] - type = type.call if type.respond_to?(:call) + index_type = options[:_type] + index_type = index_type.call if index_type.respond_to?(:call) if options[:mappings] && !options[:merge_mappings] settings = options[:settings] || {} @@ -163,7 +163,7 @@ module Searchkick settings[:analysis][:filter][:searchkick_synonym] = { type: "synonym", # only remove a single space from synonyms so three-word synonyms will fail noisily instead of silently - synonyms: synonyms.select { |s| s.size > 1 }.map { |s| s.is_a?(Array) ? s.map { |s| s.sub(/\s+/, "") }.join(",") : s }.map(&:downcase) + synonyms: synonyms.select { |s| s.size > 1 }.map { |s| s.is_a?(Array) ? s.map { |s2| s2.sub(/\s+/, "") }.join(",") : s }.map(&:downcase) } # choosing a place for the synonym filter when stemming is not easy # https://groups.google.com/forum/#!topic/elasticsearch/p7qcQlgHdB8 @@ -308,7 +308,7 @@ module Searchkick multi_field = dynamic_fields["{name}"].merge(fields: dynamic_fields.except("{name}")) mappings = { - type => { + index_type => { properties: mapping, _routing: routing, # https://gist.github.com/kimchy/2898285 diff --git a/lib/searchkick/query.rb b/lib/searchkick/query.rb index 020b8b2..cea8cae 100644 --- a/lib/searchkick/query.rb +++ b/lib/searchkick/query.rb @@ -135,7 +135,7 @@ module Searchkick if searchkick_index puts "Model Search Data" begin - pp klass.first(3).map { |r| {index: searchkick_index.record_data(r).merge(data: searchkick_index.send(:search_data, r))}} + pp(klass.first(3).map { |r| {index: searchkick_index.record_data(r).merge(data: searchkick_index.send(:search_data, r))}}) rescue => e puts "#{e.class.name}: #{e.message}" end @@ -331,7 +331,7 @@ module Searchkick end if misspellings != false && match_type == :match - 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) } + 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) }) end if field.start_with?("*.") @@ -706,7 +706,7 @@ module Searchkick ranges: agg_options[:date_ranges] }.merge(shared_agg_options) } - elsif histogram = agg_options[:date_histogram] + elsif (histogram = agg_options[:date_histogram]) interval = histogram[:interval] payload[:aggs][field] = { date_histogram: { @@ -714,7 +714,7 @@ module Searchkick interval: interval } } - elsif metric = @@metric_aggs.find { |k| agg_options.has_key?(k) } + elsif (metric = @@metric_aggs.find { |k| agg_options.has_key?(k) }) payload[:aggs][field] = { metric => { field: agg_options[metric][:field] || field diff --git a/lib/searchkick/reindex_queue.rb b/lib/searchkick/reindex_queue.rb index 49cfe2a..b806b5b 100644 --- a/lib/searchkick/reindex_queue.rb +++ b/lib/searchkick/reindex_queue.rb @@ -15,7 +15,7 @@ module Searchkick # TODO use reliable queuing def reserve(limit: 1000) record_ids = Set.new - while record_ids.size < limit && record_id = Searchkick.with_redis { |r| r.rpop(redis_key) } + while record_ids.size < limit && (record_id = Searchkick.with_redis { |r| r.rpop(redis_key) }) record_ids << record_id end record_ids.to_a -- libgit2 0.21.0