searchkick-hooopo 2.3.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (74) hide show
  1. checksums.yaml +7 -0
  2. data/.gitignore +22 -0
  3. data/.travis.yml +35 -0
  4. data/CHANGELOG.md +491 -0
  5. data/Gemfile +12 -0
  6. data/LICENSE.txt +22 -0
  7. data/README.md +1908 -0
  8. data/Rakefile +20 -0
  9. data/benchmark/Gemfile +23 -0
  10. data/benchmark/benchmark.rb +97 -0
  11. data/lib/searchkick/bulk_reindex_job.rb +17 -0
  12. data/lib/searchkick/index.rb +500 -0
  13. data/lib/searchkick/index_options.rb +333 -0
  14. data/lib/searchkick/indexer.rb +28 -0
  15. data/lib/searchkick/logging.rb +242 -0
  16. data/lib/searchkick/middleware.rb +12 -0
  17. data/lib/searchkick/model.rb +156 -0
  18. data/lib/searchkick/process_batch_job.rb +23 -0
  19. data/lib/searchkick/process_queue_job.rb +23 -0
  20. data/lib/searchkick/query.rb +901 -0
  21. data/lib/searchkick/reindex_queue.rb +38 -0
  22. data/lib/searchkick/reindex_v2_job.rb +39 -0
  23. data/lib/searchkick/results.rb +216 -0
  24. data/lib/searchkick/tasks.rb +33 -0
  25. data/lib/searchkick/version.rb +3 -0
  26. data/lib/searchkick.rb +215 -0
  27. data/searchkick.gemspec +28 -0
  28. data/test/aggs_test.rb +197 -0
  29. data/test/autocomplete_test.rb +75 -0
  30. data/test/boost_test.rb +175 -0
  31. data/test/callbacks_test.rb +59 -0
  32. data/test/ci/before_install.sh +17 -0
  33. data/test/errors_test.rb +19 -0
  34. data/test/gemfiles/activerecord31.gemfile +7 -0
  35. data/test/gemfiles/activerecord32.gemfile +7 -0
  36. data/test/gemfiles/activerecord40.gemfile +8 -0
  37. data/test/gemfiles/activerecord41.gemfile +8 -0
  38. data/test/gemfiles/activerecord42.gemfile +7 -0
  39. data/test/gemfiles/activerecord50.gemfile +7 -0
  40. data/test/gemfiles/apartment.gemfile +8 -0
  41. data/test/gemfiles/cequel.gemfile +8 -0
  42. data/test/gemfiles/mongoid2.gemfile +7 -0
  43. data/test/gemfiles/mongoid3.gemfile +6 -0
  44. data/test/gemfiles/mongoid4.gemfile +7 -0
  45. data/test/gemfiles/mongoid5.gemfile +7 -0
  46. data/test/gemfiles/mongoid6.gemfile +8 -0
  47. data/test/gemfiles/nobrainer.gemfile +8 -0
  48. data/test/gemfiles/parallel_tests.gemfile +8 -0
  49. data/test/geo_shape_test.rb +172 -0
  50. data/test/highlight_test.rb +78 -0
  51. data/test/index_test.rb +153 -0
  52. data/test/inheritance_test.rb +83 -0
  53. data/test/marshal_test.rb +8 -0
  54. data/test/match_test.rb +276 -0
  55. data/test/misspellings_test.rb +56 -0
  56. data/test/model_test.rb +42 -0
  57. data/test/multi_search_test.rb +22 -0
  58. data/test/multi_tenancy_test.rb +22 -0
  59. data/test/order_test.rb +46 -0
  60. data/test/pagination_test.rb +53 -0
  61. data/test/partial_reindex_test.rb +58 -0
  62. data/test/query_test.rb +35 -0
  63. data/test/records_test.rb +10 -0
  64. data/test/reindex_test.rb +52 -0
  65. data/test/reindex_v2_job_test.rb +32 -0
  66. data/test/routing_test.rb +23 -0
  67. data/test/should_index_test.rb +32 -0
  68. data/test/similar_test.rb +28 -0
  69. data/test/sql_test.rb +198 -0
  70. data/test/suggest_test.rb +85 -0
  71. data/test/synonyms_test.rb +67 -0
  72. data/test/test_helper.rb +527 -0
  73. data/test/where_test.rb +223 -0
  74. metadata +250 -0
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: c24ac2fb21dbee3e7c7bd8fecd68928325a296de
4
+ data.tar.gz: c44aa70c26e35e5baee5b84cfea546654fae1c90
5
+ SHA512:
6
+ metadata.gz: 708891a63da9e8942722cc6e8e7ca7476342cab05e896423516454ccf2f9b5f898333d02a55f2192fa3344e4c2afd4417cb6e1be176457e8f4087d58a1dce5cc
7
+ data.tar.gz: 0715e090239cbe7aadfc6bd0ed4ad7f1a4ac2397ebee7981bfb22cbb39e75fd0876cc94f52b69fd20baff0d6d831d71a0dd321b15da4eca40a2e781f921d2c6a
data/.gitignore ADDED
@@ -0,0 +1,22 @@
1
+ *.gem
2
+ *.rbc
3
+ .bundle
4
+ .config
5
+ .yardoc
6
+ *.lock
7
+ InstalledFiles
8
+ _yardoc
9
+ coverage
10
+ doc/
11
+ lib/bundler/man
12
+ pkg
13
+ rdoc
14
+ spec/reports
15
+ test/tmp
16
+ test/version_tmp
17
+ tmp
18
+ *.log
19
+ .DS_Store
20
+ .ruby-*
21
+ .idea/
22
+ *.sqlite3
data/.travis.yml ADDED
@@ -0,0 +1,35 @@
1
+ sudo: false
2
+ language: ruby
3
+ rvm: 2.3.1
4
+ services:
5
+ - mongodb
6
+ - redis-server
7
+ before_install:
8
+ - ./test/ci/before_install.sh
9
+ script: bundle exec rake test
10
+ before_script:
11
+ - psql -c 'create database searchkick_test;' -U postgres
12
+ notifications:
13
+ email:
14
+ on_success: never
15
+ on_failure: change
16
+ gemfile:
17
+ - Gemfile
18
+ - test/gemfiles/activerecord50.gemfile
19
+ - test/gemfiles/activerecord42.gemfile
20
+ - test/gemfiles/mongoid5.gemfile
21
+ - test/gemfiles/mongoid6.gemfile
22
+ env:
23
+ - ELASTICSEARCH_VERSION=5.4.0
24
+ jdk: oraclejdk8
25
+ matrix:
26
+ include:
27
+ - gemfile: Gemfile
28
+ env: ELASTICSEARCH_VERSION=2.0.0
29
+ jdk: oraclejdk7
30
+ - gemfile: Gemfile
31
+ env: ELASTICSEARCH_VERSION=2.4.3
32
+ jdk: oraclejdk7
33
+ - gemfile: Gemfile
34
+ env: ELASTICSEARCH_VERSION=5.0.1
35
+ jdk: oraclejdk8
data/CHANGELOG.md ADDED
@@ -0,0 +1,491 @@
1
+ ## 2.3.0
2
+
3
+ - Fixed analyzer on dynamically mapped fields
4
+ - Fixed error with `similar` method and `_all` field
5
+ - Throw error when fields are needed
6
+ - Added `queue_name` option
7
+ - No longer require synonyms to be lowercase
8
+
9
+ ## 2.2.1
10
+
11
+ - Added `avg`, `cardinality`, `max`, `min`, and `sum` aggregations
12
+ - Added `load: {dumpable: true}` option
13
+ - Added `index_suffix` option
14
+ - Accept string for `exclude` option
15
+
16
+ ## 2.2.0
17
+
18
+ - Fixed bug with text values longer than 256 characters and `_all` field - see [#850](https://github.com/ankane/searchkick/issues/850)
19
+ - Fixed issue with `_all` field in `searchable`
20
+ - Fixed `exclude` option with `word_start`
21
+
22
+ ## 2.1.1
23
+
24
+ - Fixed duplicate notifications
25
+ - Added support for `connection_pool`
26
+ - Added `exclude` option
27
+
28
+ ## 2.1.0
29
+
30
+ - Background reindexing and queues are officially supported
31
+ - Log updates and deletes
32
+
33
+ ## 2.0.4
34
+
35
+ - Added support for queuing updates [experimental]
36
+ - Added `refresh_interval` option to `reindex`
37
+ - Prefer `search_index` over `searchkick_index`
38
+
39
+ ## 2.0.3
40
+
41
+ - Added `async` option to `reindex` [experimental]
42
+ - Added `misspellings?` method to results
43
+
44
+ ## 2.0.2
45
+
46
+ - Added `retain` option to `reindex`
47
+ - Added support for attributes in highlight tags
48
+ - Fixed potentially silent errors in reindex job
49
+ - Improved syntax for `boost_by_distance`
50
+
51
+ ## 2.0.1
52
+
53
+ - Added `search_hit` and `search_highlights` methods to models
54
+ - Improved reindex performance
55
+
56
+ ## 2.0.0
57
+
58
+ - Added support for `reindex` on associations
59
+
60
+ Breaking changes
61
+
62
+ - Removed support for Elasticsearch 1 as it reaches [end of life](https://www.elastic.co/support/eol)
63
+ - Removed facets, legacy options, and legacy methods
64
+ - Invalid options now throw an `ArgumentError`
65
+ - The `query` and `json` options have been removed in favor of `body`
66
+ - The `include` option has been removed in favor of `includes`
67
+ - The `personalize` option has been removed in favor of `boost_where`
68
+ - The `partial` option has been removed in favor of `operator`
69
+ - Renamed `select_v2` to `select` (legacy `select` no longer available)
70
+ - The `_all` field is disabled if `searchable` option is used (for performance)
71
+ - The `partial_reindex(:method_name)` method has been replaced with `reindex(:method_name)`
72
+ - The `unsearchable` and `only_analyzed` options have been removed in favor of `searchable` and `filterable`
73
+ - `load: false` no longer returns an array in Elasticsearch 2
74
+
75
+ ## 1.5.1
76
+
77
+ - Added `client_options`
78
+ - Added `refresh` option to `reindex` method
79
+ - Improved syntax for partial reindex
80
+
81
+ ## 1.5.0
82
+
83
+ - Added support for geo shape indexing and queries
84
+ - Added `_and`, `_or`, `_not` to `where` option
85
+
86
+ ## 1.4.2
87
+
88
+ - Added support for directional synonyms
89
+ - Easier AWS setup
90
+ - Fixed `total_docs` method for ES 5+
91
+ - Fixed exception on update errors
92
+
93
+ ## 1.4.1
94
+
95
+ - Added `partial_reindex` method
96
+ - Added `debug` option to `search` method
97
+ - Added `profile` option
98
+
99
+ ## 1.4.0
100
+
101
+ - Official support for Elasticsearch 5
102
+ - Boost exact matches for partial matching
103
+ - Added `searchkick_debug` method
104
+ - Added `geo_polygon` filter
105
+
106
+ ## 1.3.6
107
+
108
+ - Fixed `Job adapter not found` error
109
+
110
+ ## 1.3.5
111
+
112
+ - Added support for Elasticsearch 5.0 beta
113
+ - Added `request_params` option
114
+ - Added `filterable` option
115
+
116
+ ## 1.3.4
117
+
118
+ - Added `resume` option to reindex
119
+ - Added search timeout to payload
120
+
121
+ ## 1.3.3
122
+
123
+ - Fix for namespaced models (broken in 1.3.2)
124
+
125
+ ## 1.3.2
126
+
127
+ - Added `body_options` option
128
+ - Added `date_histogram` aggregation
129
+ - Added `indices_boost` option
130
+ - Added support for multiple conversions
131
+
132
+ ## 1.3.1
133
+
134
+ - Fixed error with Ruby 2.0
135
+ - Fixed error with indexing large fields
136
+
137
+ ## 1.3.0
138
+
139
+ - Added support for Elasticsearch 5.0 alpha
140
+ - Added support for phrase matches
141
+ - Added support for procs for `index_prefix` option
142
+
143
+ ## 1.2.1
144
+
145
+ - Added `multi_search` method
146
+ - Added support for routing for Elasticsearch 2
147
+ - Added support for `search_document_id` and `search_document_type` in models
148
+ - Fixed error with instrumentation for searching multiple models
149
+ - Fixed instrumentation for bulk updates
150
+
151
+ ## 1.2.0
152
+
153
+ - Fixed deprecation warnings with `alias_method_chain`
154
+ - Added `analyzed_only` option for large text fields
155
+ - Added `encoder` option to highlight
156
+ - Fixed issue in `similar` method with `per_page` option
157
+ - Added basic support for multiple models
158
+
159
+ ## 1.1.2
160
+
161
+ - Added bulk updates with `callbacks` method
162
+ - Added `bulk_delete` method
163
+ - Added `search_timeout` option
164
+ - Fixed bug with new location format for `boost_by_distance`
165
+
166
+ ## 1.1.1
167
+
168
+ - Added support for `{lat: lat, lon: lon}` as preferred format for locations
169
+
170
+ ## 1.1.0
171
+
172
+ - Added `below` option to misspellings to improve performance
173
+ - Fixed synonyms for `word_*` partial matches
174
+ - Added `searchable` option
175
+ - Added `similarity` option
176
+ - Added `match` option
177
+ - Added `word` option
178
+ - Added highlighted fields to `load: false`
179
+
180
+ ## 1.0.3
181
+
182
+ - Added support for Elasticsearch 2.1
183
+
184
+ ## 1.0.2
185
+
186
+ - Throw `Searchkick::ImportError` for errors when importing records
187
+ - Errors now inherit from `Searchkick::Error`
188
+ - Added `order` option to aggregations
189
+ - Added `mapping` method
190
+
191
+ ## 1.0.1
192
+
193
+ - Added aggregations method to get raw response
194
+ - Use `execute: false` for lazy loading
195
+ - Return nil when no aggs
196
+ - Added emoji search
197
+
198
+ ## 1.0.0
199
+
200
+ - Added support for Elasticsearch 2.0
201
+ - Added support for aggregations
202
+ - Added ability to use misspellings for partial matches
203
+ - Added `fragment_size` option for highlight
204
+ - Added `took` method to results
205
+
206
+ Breaking changes
207
+
208
+ - Raise `Searchkick::DangerousOperation` error when calling reindex with scope
209
+ - Enabled misspellings by default for partial matches
210
+ - Enabled transpositions by default for misspellings
211
+
212
+ ## 0.9.1
213
+
214
+ - `and` now matches `&`
215
+ - Added `transpositions` option to misspellings
216
+ - Added `boost_mode` and `log` options to `boost_by`
217
+ - Added `prefix_length` option to `misspellings`
218
+ - Added ability to set env
219
+
220
+ ## 0.9.0
221
+
222
+ - Much better performance for where queries if no facets
223
+ - Added basic support for regex
224
+ - Added support for routing
225
+ - Made `Searchkick.disable_callbacks` thread-safe
226
+
227
+ ## 0.8.7
228
+
229
+ - Fixed Mongoid import
230
+
231
+ ## 0.8.6
232
+
233
+ - Added support for NoBrainer
234
+ - Added `stem_conversions: false` option
235
+ - Added support for multiple `boost_where` values on the same field
236
+ - Added support for array of values for `boost_where`
237
+ - Fixed suggestions with partial match boost
238
+ - Fixed redefining existing instance methods in models
239
+
240
+ ## 0.8.5
241
+
242
+ - Added support for Elasticsearch 1.4
243
+ - Added `unsearchable` option
244
+ - Added `select: true` option
245
+ - Added `body` option
246
+
247
+ ## 0.8.4
248
+
249
+ - Added `boost_by_distance`
250
+ - More flexible highlight options
251
+ - Better `env` logic
252
+
253
+ ## 0.8.3
254
+
255
+ - Added support for ActiveJob
256
+ - Added `timeout` setting
257
+ - Fixed import with no records
258
+
259
+ ## 0.8.2
260
+
261
+ - Added `async` to `callbacks` option
262
+ - Added `wordnet` option
263
+ - Added `edit_distance` option to eventually replace `distance` option
264
+ - Catch misspelling of `misspellings` option
265
+ - Improved logging
266
+
267
+ ## 0.8.1
268
+
269
+ - Added `search_method_name` option
270
+ - Fixed `order` for array of hashes
271
+ - Added support for Mongoid 2
272
+
273
+ ## 0.8.0
274
+
275
+ - Added support for Elasticsearch 1.2
276
+
277
+ ## 0.7.9
278
+
279
+ - Added `tokens` method
280
+ - Added `json` option
281
+ - Added exact matches
282
+ - Added `prev_page` for Kaminari pagination
283
+ - Added `import` option to reindex
284
+
285
+ ## 0.7.8
286
+
287
+ - Added `boost_by` and `boost_where` options
288
+ - Added ability to boost fields - `name^10`
289
+ - Added `select` option for `load: false`
290
+
291
+ ## 0.7.7
292
+
293
+ - Added support for automatic failover
294
+ - Fixed `operator` option (and default) for partial matches
295
+
296
+ ## 0.7.6
297
+
298
+ - Added `stats` option to facets
299
+ - Added `padding` option
300
+
301
+ ## 0.7.5
302
+
303
+ - Do not throw errors when index becomes out of sync with database
304
+ - Added custom exception types
305
+ - Fixed `offset` and `offset_value`
306
+
307
+ ## 0.7.4
308
+
309
+ - Fixed reindex with inheritance
310
+
311
+ ## 0.7.3
312
+
313
+ - Fixed multi-index searches
314
+ - Fixed suggestions for partial matches
315
+ - Added `offset` and `length` for improved pagination
316
+
317
+ ## 0.7.2
318
+
319
+ - Added smart facets
320
+ - Added more fields to `load: false` result
321
+ - Fixed logging for multi-index searches
322
+ - Added `first_page?` and `last_page?` for improved Kaminari support
323
+
324
+ ## 0.7.1
325
+
326
+ - Fixed huge issue w/ zero-downtime reindexing on 0.90
327
+
328
+ ## 0.7.0
329
+
330
+ - Added support for Elasticsearch 1.1
331
+ - Dropped support for Elasticsearch below 0.90.4 (unfortunate side effect of above)
332
+
333
+ ## 0.6.3
334
+
335
+ - Removed patron since no support for Windows
336
+ - Added error if `searchkick` is called multiple times
337
+
338
+ ## 0.6.2
339
+
340
+ - Added logging
341
+ - Fixed index_name option
342
+ - Added ability to use proc as the index name
343
+
344
+ ## 0.6.1
345
+
346
+ - Fixed huge issue w/ zero-downtime reindexing on 0.90 and elasticsearch-ruby 1.0
347
+ - Restore load: false behavior
348
+ - Restore total_entries method
349
+
350
+ ## 0.6.0
351
+
352
+ - Moved to elasticsearch-ruby
353
+ - Added support for modifying the query and viewing the response
354
+ - Added support for page_entries_info method
355
+
356
+ ## 0.5.3
357
+
358
+ - Fixed bug w/ word_* queries
359
+
360
+ ## 0.5.2
361
+
362
+ - Use after_commit hook for ActiveRecord to prevent data inconsistencies
363
+
364
+ ## 0.5.1
365
+
366
+ - Replaced stop words with common terms query
367
+ - Added language option
368
+ - Fixed bug with empty array in where clause
369
+ - Fixed bug with MongoDB integer _id
370
+ - Fixed reindex bug when callbacks disabled
371
+
372
+ ## 0.5.0
373
+
374
+ - Better control over partial matches
375
+ - Added merge_mappings option
376
+ - Added batch_size option
377
+ - Fixed bug with nil where clauses
378
+
379
+ ## 0.4.2
380
+
381
+ - Added `should_index?` method to control which records are indexed
382
+ - Added ability to temporarily disable callbacks
383
+ - Added custom mappings
384
+
385
+ ## 0.4.1
386
+
387
+ - Fixed issue w/ inheritance mapping
388
+
389
+ ## 0.4.0
390
+
391
+ - Added support for Mongoid 4
392
+ - Added support for multiple locations
393
+
394
+ ## 0.3.5
395
+
396
+ - Added facet ranges
397
+ - Added all operator
398
+
399
+ ## 0.3.4
400
+
401
+ - Added highlighting
402
+ - Added :distance option to misspellings
403
+ - Fixed issue w/ BigDecimal serialization
404
+
405
+ ## 0.3.3
406
+
407
+ - Better error messages
408
+ - Added where: {field: nil} queries
409
+
410
+ ## 0.3.2
411
+
412
+ - Added support for single table inheritance
413
+ - Removed Tire::Model::Search
414
+
415
+ ## 0.3.1
416
+
417
+ - Added index_prefix option
418
+ - Fixed ES issue with incorrect facet counts
419
+ - Added option to turn off special characters
420
+
421
+ ## 0.3.0
422
+
423
+ - Fixed reversed coordinates
424
+ - Added bounded by a box queries
425
+ - Expanded `or` queries
426
+
427
+ ## 0.2.8
428
+
429
+ - Added option to disable callbacks
430
+ - Fixed bug with facets with Elasticsearch 0.90.5
431
+
432
+ ## 0.2.7
433
+
434
+ - Added limit to facet
435
+ - Improved similar items
436
+
437
+ ## 0.2.6
438
+
439
+ - Added option to disable misspellings
440
+
441
+ ## 0.2.5
442
+
443
+ - Added geospartial searches
444
+ - Create alias before importing document if no alias exists
445
+ - Fixed exception when :per_page option is a string
446
+ - Check `RAILS_ENV` if `RACK_ENV` is not set
447
+
448
+ ## 0.2.4
449
+
450
+ - Use `to_hash` instead of `as_json` for default `search_data` method
451
+ - Works for Mongoid 1.3
452
+ - Use one shard in test environment for consistent scores
453
+
454
+ ## 0.2.3
455
+
456
+ - Setup Travis
457
+ - Clean old indices before reindex
458
+ - Search for `*` returns all results
459
+ - Fixed pagination
460
+ - Added `similar` method
461
+
462
+ ## 0.2.2
463
+
464
+ - Clean old indices after reindex
465
+ - More expansions for fuzzy queries
466
+
467
+ ## 0.2.1
468
+
469
+ - Added Rails logger
470
+ - Only fetch ids when `load: true`
471
+
472
+ ## 0.2.0
473
+
474
+ - Added autocomplete
475
+ - Added “Did you mean” suggestions
476
+ - Added personalized searches
477
+
478
+ ## 0.1.4
479
+
480
+ - Bug fix
481
+
482
+ ## 0.1.3
483
+
484
+ - Changed edit distance to one for misspellings
485
+ - Raise errors when indexing fails
486
+ - Fixed pagination
487
+ - Fixed :include option
488
+
489
+ ## 0.1.2
490
+
491
+ - Launch
data/Gemfile ADDED
@@ -0,0 +1,12 @@
1
+ source "https://rubygems.org"
2
+
3
+ # Specify your gem's dependencies in searchkick.gemspec
4
+ gemspec
5
+
6
+ gem "sqlite3"
7
+ gem "activerecord", "~> 5.1.0"
8
+ gem "gemoji-parser"
9
+ gem "typhoeus"
10
+ gem "activejob"
11
+ gem "redis"
12
+ gem "connection_pool"
data/LICENSE.txt ADDED
@@ -0,0 +1,22 @@
1
+ Copyright (c) 2013-2016 Andrew Kane
2
+
3
+ MIT License
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining
6
+ a copy of this software and associated documentation files (the
7
+ "Software"), to deal in the Software without restriction, including
8
+ without limitation the rights to use, copy, modify, merge, publish,
9
+ distribute, sublicense, and/or sell copies of the Software, and to
10
+ permit persons to whom the Software is furnished to do so, subject to
11
+ the following conditions:
12
+
13
+ The above copyright notice and this permission notice shall be
14
+ included in all copies or substantial portions of the Software.
15
+
16
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
17
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
18
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
19
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
20
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
21
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
22
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.