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
@@ -61,7 +61,7 @@ module Searchkick
61
61
  # hack to prevent generator field doesn't exist error
62
62
  if !partial_reindex
63
63
  index.suggest_fields.each do |field|
64
- if !source[field] && !source[field.to_sym]
64
+ if !source.key?(field) && !source.key?(field.to_sym)
65
65
  source[field] = nil
66
66
  end
67
67
  end
@@ -112,7 +112,7 @@ module Searchkick
112
112
  # performance
113
113
  if v.is_a?(BigDecimal)
114
114
  obj[k] = v.to_f
115
- elsif v.is_a?(Enumerable) ||
115
+ elsif v.is_a?(Enumerable)
116
116
  obj[k] = cast_big_decimal(v)
117
117
  end
118
118
  end
@@ -132,7 +132,7 @@ module Searchkick
132
132
  end
133
133
 
134
134
  def total_count
135
- response["hits"]["total"]
135
+ options[:total_entries] || response["hits"]["total"]
136
136
  end
137
137
  alias_method :total_entries, :total_count
138
138
 
@@ -195,7 +195,7 @@ module Searchkick
195
195
  end
196
196
 
197
197
  def with_highlights(multiple: false)
198
- with_hit do |result, hit|
198
+ with_hit.map do |result, hit|
199
199
  [result, hit_highlights(hit, multiple: multiple)]
200
200
  end
201
201
  end
@@ -1,3 +1,3 @@
1
1
  module Searchkick
2
- VERSION = "3.1.0"
2
+ VERSION = "3.1.1"
3
3
  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: 3.1.0
4
+ version: 3.1.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Andrew Kane
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2018-05-12 00:00:00.000000000 Z
11
+ date: 2018-08-09 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activemodel
@@ -94,26 +94,16 @@ dependencies:
94
94
  - - ">="
95
95
  - !ruby/object:Gem::Version
96
96
  version: '0'
97
- description: Intelligent search made easy
98
- email:
99
- - andrew@chartkick.com
97
+ description:
98
+ email: andrew@chartkick.com
100
99
  executables: []
101
100
  extensions: []
102
101
  extra_rdoc_files: []
103
102
  files:
104
- - ".github/ISSUE_TEMPLATE.md"
105
- - ".gitignore"
106
- - ".travis.yml"
107
103
  - CHANGELOG.md
108
104
  - CONTRIBUTING.md
109
- - Gemfile
110
105
  - LICENSE.txt
111
106
  - README.md
112
- - Rakefile
113
- - benchmark/Gemfile
114
- - benchmark/index.rb
115
- - benchmark/search.rb
116
- - docs/Searchkick-3-Upgrade.md
117
107
  - lib/searchkick.rb
118
108
  - lib/searchkick/bulk_indexer.rb
119
109
  - lib/searchkick/bulk_reindex_job.rb
@@ -135,48 +125,6 @@ files:
135
125
  - lib/searchkick/results.rb
136
126
  - lib/searchkick/tasks.rb
137
127
  - lib/searchkick/version.rb
138
- - searchkick.gemspec
139
- - test/aggs_test.rb
140
- - test/autocomplete_test.rb
141
- - test/boost_test.rb
142
- - test/callbacks_test.rb
143
- - test/ci/before_install.sh
144
- - test/errors_test.rb
145
- - test/gemfiles/activerecord42.gemfile
146
- - test/gemfiles/activerecord50.gemfile
147
- - test/gemfiles/activerecord51.gemfile
148
- - test/gemfiles/apartment.gemfile
149
- - test/gemfiles/cequel.gemfile
150
- - test/gemfiles/mongoid5.gemfile
151
- - test/gemfiles/mongoid6.gemfile
152
- - test/gemfiles/nobrainer.gemfile
153
- - test/gemfiles/parallel_tests.gemfile
154
- - test/geo_shape_test.rb
155
- - test/highlight_test.rb
156
- - test/index_test.rb
157
- - test/inheritance_test.rb
158
- - test/language_test.rb
159
- - test/marshal_test.rb
160
- - test/match_test.rb
161
- - test/misspellings_test.rb
162
- - test/model_test.rb
163
- - test/multi_search_test.rb
164
- - test/multi_tenancy_test.rb
165
- - test/order_test.rb
166
- - test/pagination_test.rb
167
- - test/partial_reindex_test.rb
168
- - test/query_test.rb
169
- - test/reindex_test.rb
170
- - test/reindex_v2_job_test.rb
171
- - test/routing_test.rb
172
- - test/should_index_test.rb
173
- - test/similar_test.rb
174
- - test/sql_test.rb
175
- - test/suggest_test.rb
176
- - test/support/kaminari.yml
177
- - test/synonyms_test.rb
178
- - test/test_helper.rb
179
- - test/where_test.rb
180
128
  homepage: https://github.com/ankane/searchkick
181
129
  licenses:
182
130
  - MIT
@@ -189,7 +137,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
189
137
  requirements:
190
138
  - - ">="
191
139
  - !ruby/object:Gem::Version
192
- version: 2.2.0
140
+ version: '2.2'
193
141
  required_rubygems_version: !ruby/object:Gem::Requirement
194
142
  requirements:
195
143
  - - ">="
@@ -197,54 +145,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
197
145
  version: '0'
198
146
  requirements: []
199
147
  rubyforge_project:
200
- rubygems_version: 2.7.6
148
+ rubygems_version: 2.7.7
201
149
  signing_key:
202
150
  specification_version: 4
203
- summary: Searchkick learns what your users are looking for. As more people search,
204
- it gets smarter and the results get better. It’s friendly for developers - and magical
205
- for your users.
206
- test_files:
207
- - benchmark/Gemfile
208
- - benchmark/index.rb
209
- - benchmark/search.rb
210
- - test/aggs_test.rb
211
- - test/autocomplete_test.rb
212
- - test/boost_test.rb
213
- - test/callbacks_test.rb
214
- - test/ci/before_install.sh
215
- - test/errors_test.rb
216
- - test/gemfiles/activerecord42.gemfile
217
- - test/gemfiles/activerecord50.gemfile
218
- - test/gemfiles/activerecord51.gemfile
219
- - test/gemfiles/apartment.gemfile
220
- - test/gemfiles/cequel.gemfile
221
- - test/gemfiles/mongoid5.gemfile
222
- - test/gemfiles/mongoid6.gemfile
223
- - test/gemfiles/nobrainer.gemfile
224
- - test/gemfiles/parallel_tests.gemfile
225
- - test/geo_shape_test.rb
226
- - test/highlight_test.rb
227
- - test/index_test.rb
228
- - test/inheritance_test.rb
229
- - test/language_test.rb
230
- - test/marshal_test.rb
231
- - test/match_test.rb
232
- - test/misspellings_test.rb
233
- - test/model_test.rb
234
- - test/multi_search_test.rb
235
- - test/multi_tenancy_test.rb
236
- - test/order_test.rb
237
- - test/pagination_test.rb
238
- - test/partial_reindex_test.rb
239
- - test/query_test.rb
240
- - test/reindex_test.rb
241
- - test/reindex_v2_job_test.rb
242
- - test/routing_test.rb
243
- - test/should_index_test.rb
244
- - test/similar_test.rb
245
- - test/sql_test.rb
246
- - test/suggest_test.rb
247
- - test/support/kaminari.yml
248
- - test/synonyms_test.rb
249
- - test/test_helper.rb
250
- - test/where_test.rb
151
+ summary: Intelligent search made easy
152
+ test_files: []
@@ -1,7 +0,0 @@
1
- Hi,
2
-
3
- Before creating an issue, please check out the Contributing Guide:
4
-
5
- https://github.com/ankane/searchkick/blob/master/CONTRIBUTING.md
6
-
7
- Thanks!
data/.gitignore DELETED
@@ -1,22 +0,0 @@
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
@@ -1,33 +0,0 @@
1
- sudo: false
2
- language: ruby
3
- rvm: 2.4.2
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/activerecord51.gemfile
19
- - test/gemfiles/activerecord50.gemfile
20
- - test/gemfiles/activerecord42.gemfile
21
- - test/gemfiles/mongoid5.gemfile
22
- - test/gemfiles/mongoid6.gemfile
23
- env:
24
- - ELASTICSEARCH_VERSION=6.2.3
25
- jdk: oraclejdk8
26
- matrix:
27
- include:
28
- - gemfile: Gemfile
29
- env: ELASTICSEARCH_VERSION=5.0.1
30
- - gemfile: Gemfile
31
- env: ELASTICSEARCH_VERSION=5.6.7
32
- - gemfile: Gemfile
33
- env: ELASTICSEARCH_VERSION=6.0.0
data/Gemfile DELETED
@@ -1,16 +0,0 @@
1
- source "https://rubygems.org"
2
-
3
- # Specify your gem's dependencies in searchkick.gemspec
4
- gemspec
5
-
6
- gem "sqlite3"
7
- gem "activerecord"
8
- gem "gemoji-parser"
9
- gem "typhoeus"
10
- gem "activejob"
11
- gem "redis"
12
- gem "connection_pool"
13
-
14
- # kaminari
15
- gem "actionpack"
16
- gem "kaminari"
data/Rakefile DELETED
@@ -1,16 +0,0 @@
1
- require "bundler/gem_tasks"
2
- require "rake/testtask"
3
-
4
- begin
5
- require "parallel_tests/tasks"
6
- require "shellwords"
7
- rescue LoadError
8
- # do nothing
9
- end
10
-
11
- task default: :test
12
- Rake::TestTask.new do |t|
13
- t.libs << "test"
14
- t.pattern = "test/**/*_test.rb"
15
- t.warning = false
16
- end
@@ -1,24 +0,0 @@
1
- source "https://rubygems.org"
2
-
3
- # Specify your gem's dependencies in searchkick.gemspec
4
- gemspec path: "../"
5
-
6
- gem "sqlite3"
7
- gem "pg"
8
- gem "activerecord", "~> 5.1.0"
9
- gem "activerecord-import"
10
- gem "activejob"
11
- gem "redis"
12
- gem "sidekiq"
13
-
14
- # performance
15
- gem "typhoeus"
16
- gem "oj"
17
-
18
- # profiling
19
- gem "ruby-prof"
20
- gem "allocation_stats"
21
- gem "get_process_mem"
22
- gem "memory_profiler"
23
- gem "allocation_tracer"
24
- gem "benchmark-ips"
@@ -1,99 +0,0 @@
1
- require "bundler/setup"
2
- Bundler.require(:default)
3
- require "active_record"
4
- require "benchmark"
5
- require "active_support/notifications"
6
-
7
- ActiveSupport::Notifications.subscribe "request.searchkick" do |*args|
8
- event = ActiveSupport::Notifications::Event.new(*args)
9
- puts "Import: #{event.duration.round}ms"
10
- end
11
-
12
- ActiveJob::Base.queue_adapter = :sidekiq
13
-
14
- Searchkick.redis = Redis.new
15
-
16
- ActiveRecord::Base.default_timezone = :utc
17
- ActiveRecord::Base.time_zone_aware_attributes = true
18
- # ActiveRecord::Base.establish_connection adapter: "sqlite3", database: "/tmp/searchkick"
19
- ActiveRecord::Base.establish_connection "postgresql://localhost/searchkick_demo_development"
20
- # ActiveRecord::Base.logger = Logger.new(STDOUT)
21
-
22
- ActiveJob::Base.logger = nil
23
-
24
- class Product < ActiveRecord::Base
25
- searchkick batch_size: 1000
26
-
27
- def search_data
28
- {
29
- name: name,
30
- color: color,
31
- store_id: store_id
32
- }
33
- end
34
- end
35
-
36
- if ENV["SETUP"]
37
- total_docs = 100000
38
-
39
- ActiveRecord::Migration.create_table :products, force: :cascade do |t|
40
- t.string :name
41
- t.string :color
42
- t.integer :store_id
43
- end
44
-
45
- Product.import ["name", "color", "store_id"], total_docs.times.map { |i| ["Product #{i}", ["red", "blue"].sample, rand(10)] }
46
-
47
- puts "Imported"
48
- end
49
-
50
- result = nil
51
- report = nil
52
- stats = nil
53
-
54
- Product.searchkick_index.delete rescue nil
55
-
56
- GC.start
57
- GC.disable
58
- start_mem = GetProcessMem.new.mb
59
-
60
- time =
61
- Benchmark.realtime do
62
- # result = RubyProf.profile do
63
- # report = MemoryProfiler.report do
64
- # stats = AllocationStats.trace do
65
- reindex = Product.reindex #(async: true)
66
- # p reindex
67
- # end
68
-
69
- # 60.times do |i|
70
- # if reindex.is_a?(Hash)
71
- # docs = Searchkick::Index.new(reindex[:index_name]).total_docs
72
- # else
73
- # docs = Product.searchkick_index.total_docs
74
- # end
75
- # puts "#{i}: #{docs}"
76
- # if docs == total_docs
77
- # break
78
- # end
79
- # p Searchkick.reindex_status(reindex[:index_name]) if reindex.is_a?(Hash)
80
- # sleep(1)
81
- # # Product.searchkick_index.refresh
82
- # end
83
- end
84
-
85
- puts
86
- puts "Time: #{time.round(1)}s"
87
-
88
- if result
89
- printer = RubyProf::GraphPrinter.new(result)
90
- printer.print(STDOUT, min_percent: 5)
91
- end
92
-
93
- if report
94
- puts report.pretty_print
95
- end
96
-
97
- if stats
98
- puts result.allocations(alias_paths: true).group_by(:sourcefile, :class).to_text
99
- end
@@ -1,48 +0,0 @@
1
- require "bundler/setup"
2
- Bundler.require(:default)
3
- require "active_record"
4
- require "benchmark/ips"
5
-
6
- ActiveRecord::Base.default_timezone = :utc
7
- ActiveRecord::Base.time_zone_aware_attributes = true
8
- ActiveRecord::Base.establish_connection adapter: "sqlite3", database: "/tmp/searchkick"
9
-
10
- class Product < ActiveRecord::Base
11
- searchkick batch_size: 1000
12
-
13
- def search_data
14
- {
15
- name: name,
16
- color: color,
17
- store_id: store_id
18
- }
19
- end
20
- end
21
-
22
- if ENV["SETUP"]
23
- total_docs = 1000000
24
-
25
- ActiveRecord::Migration.create_table :products, force: :cascade do |t|
26
- t.string :name
27
- t.string :color
28
- t.integer :store_id
29
- end
30
-
31
- Product.import ["name", "color", "store_id"], total_docs.times.map { |i| ["Product #{i}", ["red", "blue"].sample, rand(10)] }
32
-
33
- puts "Imported"
34
-
35
- Product.reindex
36
-
37
- puts "Reindexed"
38
- end
39
-
40
- query = Product.search("product", fields: [:name], where: {color: "red", store_id: 5}, limit: 10000, load: false, execute: false)
41
-
42
- require "pp"
43
- pp query.body.as_json
44
- puts
45
-
46
- Benchmark.ips do |x|
47
- x.report { query.dup.execute }
48
- end