test/test_helper.rb in searchkick-1.5.1 vs test/test_helper.rb in searchkick-2.0.0
- old
+ new
@@ -27,51 +27,20 @@
def elasticsearch_below22?
Searchkick.server_below?("2.2.0")
end
-def elasticsearch_below20?
- Searchkick.server_below?("2.0.0")
-end
-
-def elasticsearch_below14?
- Searchkick.server_below?("1.4.0")
-end
-
-def mongoid2?
- defined?(Mongoid) && Mongoid::VERSION.starts_with?("2.")
-end
-
def nobrainer?
defined?(NoBrainer)
end
-def activerecord_below41?
- defined?(ActiveRecord) && Gem::Version.new(ActiveRecord::VERSION::STRING) < Gem::Version.new("4.1.0")
-end
-
if defined?(Mongoid)
Mongoid.logger.level = Logger::INFO
Mongo::Logger.logger.level = Logger::INFO if defined?(Mongo::Logger)
- if mongoid2?
- # enable comparison of BSON::ObjectIds
- module BSON
- class ObjectId
- def <=>(other)
- data <=> other.data
- end
- end
- end
- end
-
Mongoid.configure do |config|
- if mongoid2?
- config.master = Mongo::Connection.new.db("searchkick_test")
- else
- config.connect_to "searchkick_test"
- end
+ config.connect_to "searchkick_test"
end
class Product
include Mongoid::Document
include Mongoid::Timestamps
@@ -301,27 +270,23 @@
["burger", "hamburger"],
["bandaid", "bandag"],
"lightbulb => led,lightbulb",
"lightbulb => halogenlamp"
],
- autocomplete: [:name],
suggest: [:name, :color],
conversions: [:conversions],
- personalize: :user_ids,
locations: [:location, :multiple_locations],
text_start: [:name],
text_middle: [:name],
text_end: [:name],
word_start: [:name],
word_middle: [:name],
word_end: [:name],
highlight: [:name],
searchable: [:name, :color],
- default_fields: [:name, :color],
filterable: [:name, :color, :description],
- # unsearchable: [:description],
- # only_analyzed: [:alt_description],
+ similarity: "BM25",
match: ENV["MATCH"] ? ENV["MATCH"].to_sym : nil
attr_accessor :conversions, :user_ids, :aisle, :details
def search_data
@@ -399,10 +364,10 @@
end
end
class Animal
searchkick \
- autocomplete: [:name],
+ text_start: [:name],
suggest: [:name],
index_name: -> { "#{name.tableize}-#{Date.today.year}" }
# wordnet: true
end