searchkick 3.1.0 → 3.1.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (63) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +9 -0
  3. data/CONTRIBUTING.md +9 -7
  4. data/README.md +86 -24
  5. data/lib/searchkick/bulk_indexer.rb +1 -1
  6. data/lib/searchkick/index_options.rb +12 -0
  7. data/lib/searchkick/model.rb +2 -2
  8. data/lib/searchkick/query.rb +36 -21
  9. data/lib/searchkick/record_data.rb +2 -2
  10. data/lib/searchkick/results.rb +2 -2
  11. data/lib/searchkick/version.rb +1 -1
  12. metadata +8 -106
  13. data/.github/ISSUE_TEMPLATE.md +0 -7
  14. data/.gitignore +0 -22
  15. data/.travis.yml +0 -33
  16. data/Gemfile +0 -16
  17. data/Rakefile +0 -16
  18. data/benchmark/Gemfile +0 -24
  19. data/benchmark/index.rb +0 -99
  20. data/benchmark/search.rb +0 -48
  21. data/docs/Searchkick-3-Upgrade.md +0 -57
  22. data/searchkick.gemspec +0 -30
  23. data/test/aggs_test.rb +0 -217
  24. data/test/autocomplete_test.rb +0 -81
  25. data/test/boost_test.rb +0 -225
  26. data/test/callbacks_test.rb +0 -59
  27. data/test/ci/before_install.sh +0 -17
  28. data/test/errors_test.rb +0 -19
  29. data/test/gemfiles/activerecord42.gemfile +0 -7
  30. data/test/gemfiles/activerecord50.gemfile +0 -7
  31. data/test/gemfiles/activerecord51.gemfile +0 -7
  32. data/test/gemfiles/apartment.gemfile +0 -8
  33. data/test/gemfiles/cequel.gemfile +0 -8
  34. data/test/gemfiles/mongoid5.gemfile +0 -7
  35. data/test/gemfiles/mongoid6.gemfile +0 -12
  36. data/test/gemfiles/nobrainer.gemfile +0 -8
  37. data/test/gemfiles/parallel_tests.gemfile +0 -8
  38. data/test/geo_shape_test.rb +0 -171
  39. data/test/highlight_test.rb +0 -109
  40. data/test/index_test.rb +0 -168
  41. data/test/inheritance_test.rb +0 -82
  42. data/test/language_test.rb +0 -79
  43. data/test/marshal_test.rb +0 -13
  44. data/test/match_test.rb +0 -293
  45. data/test/misspellings_test.rb +0 -56
  46. data/test/model_test.rb +0 -40
  47. data/test/multi_search_test.rb +0 -37
  48. data/test/multi_tenancy_test.rb +0 -22
  49. data/test/order_test.rb +0 -40
  50. data/test/pagination_test.rb +0 -96
  51. data/test/partial_reindex_test.rb +0 -65
  52. data/test/query_test.rb +0 -43
  53. data/test/reindex_test.rb +0 -87
  54. data/test/reindex_v2_job_test.rb +0 -27
  55. data/test/routing_test.rb +0 -23
  56. data/test/should_index_test.rb +0 -32
  57. data/test/similar_test.rb +0 -28
  58. data/test/sql_test.rb +0 -190
  59. data/test/suggest_test.rb +0 -100
  60. data/test/support/kaminari.yml +0 -21
  61. data/test/synonyms_test.rb +0 -69
  62. data/test/test_helper.rb +0 -593
  63. data/test/where_test.rb +0 -249
@@ -1,249 +0,0 @@
1
- require_relative "test_helper"
2
-
3
- class WhereTest < Minitest::Test
4
- def test_where
5
- now = Time.now
6
- store [
7
- {name: "Product A", store_id: 1, in_stock: true, backordered: true, created_at: now, orders_count: 4, user_ids: [1, 2, 3]},
8
- {name: "Product B", store_id: 2, in_stock: true, backordered: false, created_at: now - 1, orders_count: 3, user_ids: [1]},
9
- {name: "Product C", store_id: 3, in_stock: false, backordered: true, created_at: now - 2, orders_count: 2, user_ids: [1, 3]},
10
- {name: "Product D", store_id: 4, in_stock: false, backordered: false, created_at: now - 3, orders_count: 1}
11
- ]
12
- assert_search "product", ["Product A", "Product B"], where: {in_stock: true}
13
-
14
- # due to precision
15
- unless cequel?
16
- # date
17
- assert_search "product", ["Product A"], where: {created_at: {gt: now - 1}}
18
- assert_search "product", ["Product A", "Product B"], where: {created_at: {gte: now - 1}}
19
- assert_search "product", ["Product D"], where: {created_at: {lt: now - 2}}
20
- assert_search "product", ["Product C", "Product D"], where: {created_at: {lte: now - 2}}
21
- end
22
-
23
- # integer
24
- assert_search "product", ["Product A"], where: {store_id: {lt: 2}}
25
- assert_search "product", ["Product A", "Product B"], where: {store_id: {lte: 2}}
26
- assert_search "product", ["Product D"], where: {store_id: {gt: 3}}
27
- assert_search "product", ["Product C", "Product D"], where: {store_id: {gte: 3}}
28
-
29
- # range
30
- assert_search "product", ["Product A", "Product B"], where: {store_id: 1..2}
31
- assert_search "product", ["Product A"], where: {store_id: 1...2}
32
- assert_search "product", ["Product A", "Product B"], where: {store_id: [1, 2]}
33
- assert_search "product", ["Product B", "Product C", "Product D"], where: {store_id: {not: 1}}
34
- assert_search "product", ["Product B", "Product C", "Product D"], where: {store_id: {_not: 1}}
35
- assert_search "product", ["Product C", "Product D"], where: {store_id: {not: [1, 2]}}
36
- assert_search "product", ["Product C", "Product D"], where: {store_id: {_not: [1, 2]}}
37
- assert_search "product", ["Product A"], where: {user_ids: {lte: 2, gte: 2}}
38
-
39
- # or
40
- assert_search "product", ["Product A", "Product B", "Product C"], where: {or: [[{in_stock: true}, {store_id: 3}]]}
41
- assert_search "product", ["Product A", "Product B", "Product C"], where: {or: [[{orders_count: [2, 4]}, {store_id: [1, 2]}]]}
42
- assert_search "product", ["Product A", "Product D"], where: {or: [[{orders_count: 1}, {created_at: {gte: now - 1}, backordered: true}]]}
43
-
44
- # _or
45
- assert_search "product", ["Product A", "Product B", "Product C"], where: {_or: [{in_stock: true}, {store_id: 3}]}
46
- assert_search "product", ["Product A", "Product B", "Product C"], where: {_or: [{orders_count: [2, 4]}, {store_id: [1, 2]}]}
47
- assert_search "product", ["Product A", "Product D"], where: {_or: [{orders_count: 1}, {created_at: {gte: now - 1}, backordered: true}]}
48
-
49
- # _and
50
- assert_search "product", ["Product A"], where: {_and: [{in_stock: true}, {backordered: true}]}
51
-
52
- # _not
53
- assert_search "product", ["Product B", "Product C"], where: {_not: {_or: [{orders_count: 1}, {created_at: {gte: now - 1}, backordered: true}]}}
54
-
55
- # all
56
- assert_search "product", ["Product A", "Product C"], where: {user_ids: {all: [1, 3]}}
57
- assert_search "product", [], where: {user_ids: {all: [1, 2, 3, 4]}}
58
-
59
- # any / nested terms
60
- assert_search "product", ["Product B", "Product C"], where: {user_ids: {not: [2], in: [1, 3]}}
61
- assert_search "product", ["Product B", "Product C"], where: {user_ids: {_not: [2], in: [1, 3]}}
62
-
63
- # not / exists
64
- assert_search "product", ["Product D"], where: {user_ids: nil}
65
- assert_search "product", ["Product A", "Product B", "Product C"], where: {user_ids: {not: nil}}
66
- assert_search "product", ["Product A", "Product B", "Product C"], where: {user_ids: {_not: nil}}
67
- assert_search "product", ["Product A", "Product C", "Product D"], where: {user_ids: [3, nil]}
68
- assert_search "product", ["Product B"], where: {user_ids: {not: [3, nil]}}
69
- assert_search "product", ["Product B"], where: {user_ids: {_not: [3, nil]}}
70
- end
71
-
72
- def test_regexp
73
- store_names ["Product A"]
74
- assert_search "*", ["Product A"], where: {name: /Pro.+/}
75
- end
76
-
77
- def test_alternate_regexp
78
- store_names ["Product A", "Item B"]
79
- assert_search "*", ["Product A"], where: {name: {regexp: "Pro.+"}}
80
- end
81
-
82
- def test_special_regexp
83
- store_names ["Product <A>", "Item <B>"]
84
- assert_search "*", ["Product <A>"], where: {name: /Pro.+<.+/}
85
- end
86
-
87
- def test_where_string
88
- store [
89
- {name: "Product A", color: "RED"}
90
- ]
91
- assert_search "product", ["Product A"], where: {color: "RED"}
92
- end
93
-
94
- def test_where_nil
95
- store [
96
- {name: "Product A"},
97
- {name: "Product B", color: "red"}
98
- ]
99
- assert_search "product", ["Product A"], where: {color: nil}
100
- end
101
-
102
- def test_where_id
103
- store_names ["Product A"]
104
- product = Product.first
105
- assert_search "product", ["Product A"], where: {id: product.id.to_s}
106
- end
107
-
108
- def test_where_empty
109
- store_names ["Product A"]
110
- assert_search "product", ["Product A"], where: {}
111
- end
112
-
113
- def test_where_empty_array
114
- store_names ["Product A"]
115
- assert_search "product", [], where: {store_id: []}
116
- end
117
-
118
- # http://elasticsearch-users.115913.n3.nabble.com/Numeric-range-quey-or-filter-in-an-array-field-possible-or-not-td4042967.html
119
- # https://gist.github.com/jprante/7099463
120
- def test_where_range_array
121
- store [
122
- {name: "Product A", user_ids: [11, 23, 13, 16, 17, 23]},
123
- {name: "Product B", user_ids: [1, 2, 3, 4, 5, 6, 7, 8, 9]},
124
- {name: "Product C", user_ids: [101, 230, 150, 200]}
125
- ]
126
- assert_search "product", ["Product A"], where: {user_ids: {gt: 10, lt: 24}}
127
- end
128
-
129
- def test_where_range_array_again
130
- store [
131
- {name: "Product A", user_ids: [19, 32, 42]},
132
- {name: "Product B", user_ids: [13, 40, 52]}
133
- ]
134
- assert_search "product", ["Product A"], where: {user_ids: {gt: 26, lt: 36}}
135
- end
136
-
137
- def test_near
138
- store [
139
- {name: "San Francisco", latitude: 37.7833, longitude: -122.4167},
140
- {name: "San Antonio", latitude: 29.4167, longitude: -98.5000}
141
- ]
142
- assert_search "san", ["San Francisco"], where: {location: {near: [37.5, -122.5]}}
143
- end
144
-
145
- def test_near_hash
146
- store [
147
- {name: "San Francisco", latitude: 37.7833, longitude: -122.4167},
148
- {name: "San Antonio", latitude: 29.4167, longitude: -98.5000}
149
- ]
150
- assert_search "san", ["San Francisco"], where: {location: {near: {lat: 37.5, lon: -122.5}}}
151
- end
152
-
153
- def test_near_within
154
- store [
155
- {name: "San Francisco", latitude: 37.7833, longitude: -122.4167},
156
- {name: "San Antonio", latitude: 29.4167, longitude: -98.5000},
157
- {name: "San Marino", latitude: 43.9333, longitude: 12.4667}
158
- ]
159
- assert_search "san", ["San Francisco", "San Antonio"], where: {location: {near: [37, -122], within: "2000mi"}}
160
- end
161
-
162
- def test_near_within_hash
163
- store [
164
- {name: "San Francisco", latitude: 37.7833, longitude: -122.4167},
165
- {name: "San Antonio", latitude: 29.4167, longitude: -98.5000},
166
- {name: "San Marino", latitude: 43.9333, longitude: 12.4667}
167
- ]
168
- assert_search "san", ["San Francisco", "San Antonio"], where: {location: {near: {lat: 37, lon: -122}, within: "2000mi"}}
169
- end
170
-
171
- def test_geo_polygon
172
- store [
173
- {name: "San Francisco", latitude: 37.7833, longitude: -122.4167},
174
- {name: "San Antonio", latitude: 29.4167, longitude: -98.5000},
175
- {name: "San Marino", latitude: 43.9333, longitude: 12.4667}
176
- ]
177
- polygon = [
178
- {lat: 42.185695, lon: -125.496146},
179
- {lat: 42.185695, lon: -94.125535},
180
- {lat: 27.122789, lon: -94.125535},
181
- {lat: 27.12278, lon: -125.496146}
182
- ]
183
- assert_search "san", ["San Francisco", "San Antonio"], where: {location: {geo_polygon: {points: polygon}}}
184
- end
185
-
186
- def test_top_left_bottom_right
187
- store [
188
- {name: "San Francisco", latitude: 37.7833, longitude: -122.4167},
189
- {name: "San Antonio", latitude: 29.4167, longitude: -98.5000}
190
- ]
191
- assert_search "san", ["San Francisco"], where: {location: {top_left: [38, -123], bottom_right: [37, -122]}}
192
- end
193
-
194
- def test_top_left_bottom_right_hash
195
- store [
196
- {name: "San Francisco", latitude: 37.7833, longitude: -122.4167},
197
- {name: "San Antonio", latitude: 29.4167, longitude: -98.5000}
198
- ]
199
- assert_search "san", ["San Francisco"], where: {location: {top_left: {lat: 38, lon: -123}, bottom_right: {lat: 37, lon: -122}}}
200
- end
201
-
202
- def test_top_right_bottom_left
203
- store [
204
- {name: "San Francisco", latitude: 37.7833, longitude: -122.4167},
205
- {name: "San Antonio", latitude: 29.4167, longitude: -98.5000}
206
- ]
207
- assert_search "san", ["San Francisco"], where: {location: {top_right: [38, -122], bottom_left: [37, -123]}}
208
- end
209
-
210
- def test_top_right_bottom_left_hash
211
- store [
212
- {name: "San Francisco", latitude: 37.7833, longitude: -122.4167},
213
- {name: "San Antonio", latitude: 29.4167, longitude: -98.5000}
214
- ]
215
- assert_search "san", ["San Francisco"], where: {location: {top_right: {lat: 38, lon: -122}, bottom_left: {lat: 37, lon: -123}}}
216
- end
217
-
218
- def test_multiple_locations
219
- store [
220
- {name: "San Francisco", latitude: 37.7833, longitude: -122.4167},
221
- {name: "San Antonio", latitude: 29.4167, longitude: -98.5000}
222
- ]
223
- assert_search "san", ["San Francisco"], where: {multiple_locations: {near: [37.5, -122.5]}}
224
- end
225
-
226
- def test_multiple_locations_with_term_filter
227
- store [
228
- {name: "San Francisco", latitude: 37.7833, longitude: -122.4167},
229
- {name: "San Antonio", latitude: 29.4167, longitude: -98.5000}
230
- ]
231
- assert_search "san", [], where: {multiple_locations: {near: [37.5, -122.5]}, name: "San Antonio"}
232
- assert_search "san", ["San Francisco"], where: {multiple_locations: {near: [37.5, -122.5]}, name: "San Francisco"}
233
- end
234
-
235
- def test_multiple_locations_hash
236
- store [
237
- {name: "San Francisco", latitude: 37.7833, longitude: -122.4167},
238
- {name: "San Antonio", latitude: 29.4167, longitude: -98.5000}
239
- ]
240
- assert_search "san", ["San Francisco"], where: {multiple_locations: {near: {lat: 37.5, lon: -122.5}}}
241
- end
242
-
243
- def test_nested
244
- store [
245
- {name: "Product A", details: {year: 2016}}
246
- ]
247
- assert_search "product", ["Product A"], where: {"details.year" => 2016}
248
- end
249
- end