searchkick 0.9.1 → 1.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/.travis.yml +10 -9
- data/CHANGELOG.md +14 -0
- data/README.md +190 -14
- data/lib/searchkick.rb +1 -0
- data/lib/searchkick/index.rb +8 -8
- data/lib/searchkick/logging.rb +4 -2
- data/lib/searchkick/model.rb +13 -10
- data/lib/searchkick/query.rb +107 -39
- data/lib/searchkick/reindex_job.rb +0 -2
- data/lib/searchkick/reindex_v2_job.rb +0 -1
- data/lib/searchkick/results.rb +18 -1
- data/lib/searchkick/tasks.rb +0 -2
- data/lib/searchkick/version.rb +1 -1
- data/test/aggs_test.rb +102 -0
- data/test/autocomplete_test.rb +1 -3
- data/test/boost_test.rb +1 -3
- data/{ci → test/ci}/before_install.sh +4 -3
- data/test/facets_test.rb +4 -6
- data/{gemfiles → test/gemfiles}/activerecord31.gemfile +1 -1
- data/{gemfiles → test/gemfiles}/activerecord32.gemfile +1 -1
- data/{gemfiles → test/gemfiles}/activerecord40.gemfile +1 -1
- data/{gemfiles → test/gemfiles}/activerecord41.gemfile +1 -1
- data/{gemfiles → test/gemfiles}/mongoid2.gemfile +1 -1
- data/{gemfiles → test/gemfiles}/mongoid3.gemfile +1 -1
- data/{gemfiles → test/gemfiles}/mongoid4.gemfile +1 -1
- data/test/gemfiles/mongoid5.gemfile +7 -0
- data/{gemfiles → test/gemfiles}/nobrainer.gemfile +1 -1
- data/test/highlight_test.rb +2 -4
- data/test/index_test.rb +20 -9
- data/test/inheritance_test.rb +1 -3
- data/test/match_test.rb +8 -7
- data/test/model_test.rb +2 -4
- data/test/query_test.rb +1 -3
- data/test/records_test.rb +0 -2
- data/test/reindex_job_test.rb +1 -3
- data/test/reindex_v2_job_test.rb +1 -3
- data/test/routing_test.rb +4 -3
- data/test/should_index_test.rb +1 -3
- data/test/similar_test.rb +1 -3
- data/test/sql_test.rb +7 -9
- data/test/suggest_test.rb +1 -3
- data/test/synonyms_test.rb +1 -3
- data/test/test_helper.rb +23 -10
- metadata +24 -11
data/test/suggest_test.rb
CHANGED
@@ -1,7 +1,6 @@
|
|
1
1
|
require_relative "test_helper"
|
2
2
|
|
3
|
-
class
|
4
|
-
|
3
|
+
class SuggestTest < Minitest::Test
|
5
4
|
def test_basic
|
6
5
|
store_names ["Great White Shark", "Hammerhead Shark", "Tiger Shark"]
|
7
6
|
assert_suggest "How Big is a Tigre Shar", "how big is a tiger shark", fields: [:name]
|
@@ -78,5 +77,4 @@ class TestSuggest < Minitest::Test
|
|
78
77
|
def assert_suggest_all(term, expected, options = {})
|
79
78
|
assert_equal expected.sort, Product.search(term, options.merge(suggest: true)).suggestions.sort
|
80
79
|
end
|
81
|
-
|
82
80
|
end
|
data/test/synonyms_test.rb
CHANGED
@@ -1,7 +1,6 @@
|
|
1
1
|
require_relative "test_helper"
|
2
2
|
|
3
|
-
class
|
4
|
-
|
3
|
+
class SynonymsTest < Minitest::Test
|
5
4
|
def test_bleach
|
6
5
|
store_names ["Clorox Bleach", "Kroger Bleach"]
|
7
6
|
assert_search "clorox", ["Clorox Bleach", "Kroger Bleach"]
|
@@ -46,5 +45,4 @@ class TestSynonyms < Minitest::Test
|
|
46
45
|
# store_names ["Creature", "Beast", "Dragon"], Animal
|
47
46
|
# assert_search "animal", ["Creature", "Beast"], {}, Animal
|
48
47
|
# end
|
49
|
-
|
50
48
|
end
|
data/test/test_helper.rb
CHANGED
@@ -3,6 +3,7 @@ Bundler.require(:default)
|
|
3
3
|
require "minitest/autorun"
|
4
4
|
require "minitest/pride"
|
5
5
|
require "logger"
|
6
|
+
require "active_support/core_ext" if defined?(NoBrainer)
|
6
7
|
|
7
8
|
ENV["RACK_ENV"] = "test"
|
8
9
|
|
@@ -17,11 +18,25 @@ I18n.config.enforce_available_locales = true
|
|
17
18
|
|
18
19
|
ActiveJob::Base.logger = nil if defined?(ActiveJob)
|
19
20
|
|
20
|
-
|
21
|
+
def elasticsearch2?
|
22
|
+
Searchkick.server_version.starts_with?("2.")
|
23
|
+
end
|
21
24
|
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
+
def mongoid2?
|
26
|
+
defined?(Mongoid) && Mongoid::VERSION.starts_with?("2.")
|
27
|
+
end
|
28
|
+
|
29
|
+
def nobrainer?
|
30
|
+
defined?(NoBrainer)
|
31
|
+
end
|
32
|
+
|
33
|
+
def activerecord_below41?
|
34
|
+
defined?(ActiveRecord) && Gem::Version.new(ActiveRecord::VERSION::STRING) < Gem::Version.new("4.1.0")
|
35
|
+
end
|
36
|
+
|
37
|
+
if defined?(Mongoid)
|
38
|
+
Mongoid.logger.level = Logger::INFO
|
39
|
+
Mongo::Logger.logger.level = Logger::INFO if defined?(Mongo::Logger)
|
25
40
|
|
26
41
|
if mongoid2?
|
27
42
|
# enable comparison of BSON::ObjectIds
|
@@ -96,7 +111,7 @@ elsif defined?(NoBrainer)
|
|
96
111
|
field :color, type: String
|
97
112
|
field :latitude
|
98
113
|
field :longitude
|
99
|
-
field :description,
|
114
|
+
field :description, type: String
|
100
115
|
|
101
116
|
belongs_to :store, validates: false
|
102
117
|
end
|
@@ -220,15 +235,15 @@ end
|
|
220
235
|
|
221
236
|
class Store
|
222
237
|
searchkick \
|
223
|
-
routing: :name,
|
238
|
+
routing: elasticsearch2? ? false : "name",
|
224
239
|
merge_mappings: true,
|
225
240
|
mappings: {
|
226
241
|
store: {
|
227
242
|
properties: {
|
228
|
-
name: {type: "string", analyzer: "keyword"}
|
243
|
+
name: {type: "string", analyzer: "keyword"}
|
229
244
|
}
|
230
245
|
}
|
231
|
-
|
246
|
+
}
|
232
247
|
end
|
233
248
|
|
234
249
|
class Animal
|
@@ -247,7 +262,6 @@ Store.reindex
|
|
247
262
|
Animal.reindex
|
248
263
|
|
249
264
|
class Minitest::Test
|
250
|
-
|
251
265
|
def setup
|
252
266
|
Product.destroy_all
|
253
267
|
Store.destroy_all
|
@@ -279,5 +293,4 @@ class Minitest::Test
|
|
279
293
|
def assert_first(term, expected, options = {}, klass = Product)
|
280
294
|
assert_equal expected, klass.search(term, options).map(&:name).first
|
281
295
|
end
|
282
|
-
|
283
296
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: searchkick
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 1.0.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Andrew Kane
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2015-
|
11
|
+
date: 2015-10-30 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: activemodel
|
@@ -108,15 +108,6 @@ files:
|
|
108
108
|
- LICENSE.txt
|
109
109
|
- README.md
|
110
110
|
- Rakefile
|
111
|
-
- ci/before_install.sh
|
112
|
-
- gemfiles/activerecord31.gemfile
|
113
|
-
- gemfiles/activerecord32.gemfile
|
114
|
-
- gemfiles/activerecord40.gemfile
|
115
|
-
- gemfiles/activerecord41.gemfile
|
116
|
-
- gemfiles/mongoid2.gemfile
|
117
|
-
- gemfiles/mongoid3.gemfile
|
118
|
-
- gemfiles/mongoid4.gemfile
|
119
|
-
- gemfiles/nobrainer.gemfile
|
120
111
|
- lib/searchkick.rb
|
121
112
|
- lib/searchkick/index.rb
|
122
113
|
- lib/searchkick/logging.rb
|
@@ -128,9 +119,20 @@ files:
|
|
128
119
|
- lib/searchkick/tasks.rb
|
129
120
|
- lib/searchkick/version.rb
|
130
121
|
- searchkick.gemspec
|
122
|
+
- test/aggs_test.rb
|
131
123
|
- test/autocomplete_test.rb
|
132
124
|
- test/boost_test.rb
|
125
|
+
- test/ci/before_install.sh
|
133
126
|
- test/facets_test.rb
|
127
|
+
- test/gemfiles/activerecord31.gemfile
|
128
|
+
- test/gemfiles/activerecord32.gemfile
|
129
|
+
- test/gemfiles/activerecord40.gemfile
|
130
|
+
- test/gemfiles/activerecord41.gemfile
|
131
|
+
- test/gemfiles/mongoid2.gemfile
|
132
|
+
- test/gemfiles/mongoid3.gemfile
|
133
|
+
- test/gemfiles/mongoid4.gemfile
|
134
|
+
- test/gemfiles/mongoid5.gemfile
|
135
|
+
- test/gemfiles/nobrainer.gemfile
|
134
136
|
- test/highlight_test.rb
|
135
137
|
- test/index_test.rb
|
136
138
|
- test/inheritance_test.rb
|
@@ -174,9 +176,20 @@ summary: Searchkick learns what your users are looking for. As more people searc
|
|
174
176
|
it gets smarter and the results get better. It’s friendly for developers - and magical
|
175
177
|
for your users.
|
176
178
|
test_files:
|
179
|
+
- test/aggs_test.rb
|
177
180
|
- test/autocomplete_test.rb
|
178
181
|
- test/boost_test.rb
|
182
|
+
- test/ci/before_install.sh
|
179
183
|
- test/facets_test.rb
|
184
|
+
- test/gemfiles/activerecord31.gemfile
|
185
|
+
- test/gemfiles/activerecord32.gemfile
|
186
|
+
- test/gemfiles/activerecord40.gemfile
|
187
|
+
- test/gemfiles/activerecord41.gemfile
|
188
|
+
- test/gemfiles/mongoid2.gemfile
|
189
|
+
- test/gemfiles/mongoid3.gemfile
|
190
|
+
- test/gemfiles/mongoid4.gemfile
|
191
|
+
- test/gemfiles/mongoid5.gemfile
|
192
|
+
- test/gemfiles/nobrainer.gemfile
|
180
193
|
- test/highlight_test.rb
|
181
194
|
- test/index_test.rb
|
182
195
|
- test/inheritance_test.rb
|