indexers 4.1.0.1 → 5.1.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (61) hide show
  1. checksums.yaml +4 -4
  2. data/MIT-LICENSE +1 -1
  3. data/README.md +17 -23
  4. data/Rakefile +1 -3
  5. data/lib/indexers.rb +1 -1
  6. data/lib/indexers/collection.rb +10 -12
  7. data/lib/indexers/concern.rb +1 -1
  8. data/lib/indexers/version.rb +1 -1
  9. metadata +18 -129
  10. data/test/dsl_test.rb +0 -127
  11. data/test/dummy/Rakefile +0 -5
  12. data/test/dummy/app/assets/javascripts/application.js +0 -13
  13. data/test/dummy/app/assets/stylesheets/application.css +0 -15
  14. data/test/dummy/app/controllers/application_controller.rb +0 -5
  15. data/test/dummy/app/helpers/application_helper.rb +0 -2
  16. data/test/dummy/app/indexers/product_indexer.rb +0 -55
  17. data/test/dummy/app/indexers/shop_indexer.rb +0 -28
  18. data/test/dummy/app/models/product.rb +0 -5
  19. data/test/dummy/app/models/shop.rb +0 -5
  20. data/test/dummy/app/views/layouts/application.html.erb +0 -12
  21. data/test/dummy/bin/bundle +0 -4
  22. data/test/dummy/bin/rails +0 -5
  23. data/test/dummy/bin/rake +0 -5
  24. data/test/dummy/bin/setup +0 -30
  25. data/test/dummy/config.ru +0 -4
  26. data/test/dummy/config/application.rb +0 -25
  27. data/test/dummy/config/boot.rb +0 -5
  28. data/test/dummy/config/database.yml +0 -10
  29. data/test/dummy/config/database.yml.travis +0 -3
  30. data/test/dummy/config/elasticsearch.yml +0 -15
  31. data/test/dummy/config/environment.rb +0 -5
  32. data/test/dummy/config/environments/development.rb +0 -41
  33. data/test/dummy/config/environments/production.rb +0 -79
  34. data/test/dummy/config/environments/test.rb +0 -42
  35. data/test/dummy/config/initializers/assets.rb +0 -11
  36. data/test/dummy/config/initializers/backtrace_silencers.rb +0 -7
  37. data/test/dummy/config/initializers/cookies_serializer.rb +0 -3
  38. data/test/dummy/config/initializers/filter_parameter_logging.rb +0 -4
  39. data/test/dummy/config/initializers/indexers.rb +0 -65
  40. data/test/dummy/config/initializers/inflections.rb +0 -16
  41. data/test/dummy/config/initializers/mime_types.rb +0 -4
  42. data/test/dummy/config/initializers/session_store.rb +0 -3
  43. data/test/dummy/config/initializers/wrap_parameters.rb +0 -14
  44. data/test/dummy/config/locales/en.yml +0 -23
  45. data/test/dummy/config/routes.rb +0 -56
  46. data/test/dummy/config/secrets.yml +0 -22
  47. data/test/dummy/db/migrate/20161104164148_create_products.rb +0 -14
  48. data/test/dummy/db/migrate/20161104182219_create_shops.rb +0 -9
  49. data/test/dummy/db/schema.rb +0 -36
  50. data/test/dummy/log/development.log +0 -114
  51. data/test/dummy/log/test.log +0 -21168
  52. data/test/dummy/public/404.html +0 -61
  53. data/test/dummy/public/422.html +0 -61
  54. data/test/dummy/public/500.html +0 -60
  55. data/test/dummy/public/favicon.ico +0 -0
  56. data/test/generator_test.rb +0 -26
  57. data/test/index_test.rb +0 -42
  58. data/test/record_test.rb +0 -25
  59. data/test/search_test.rb +0 -164
  60. data/test/task_test.rb +0 -31
  61. data/test/test_helper.rb +0 -14
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: dfb6293d7448565833f062e82462c5102f531056
4
- data.tar.gz: c9d4d54d81642f3640b43c4885264e748fe1a51d
3
+ metadata.gz: 3cd1b4b219caffd4cd86cf1f86a49aaa90fe8911
4
+ data.tar.gz: 6fd8d22673623460b65ecd70c6d1655f4baa02fb
5
5
  SHA512:
6
- metadata.gz: eb6e00eaec82bfb722c58cce834acaa29e95a0ab016f18baf16fcc5633b391630ad83b13d2be47a057d3745b0d36b0b8c78ac91d40db633773937dde2541fdef
7
- data.tar.gz: b9cb8483b777d4115ae227b969c7672aacd6d8c80c32f07f35e930055ee220175a6e8c88f86298e32560d2dbba32859fd1d22573fc38348e1022833d64bc5672
6
+ metadata.gz: 2bbf0c594fd26479d00c5a9fa69782b22d64427b145126e9f1ed7d7178dae78e089ab2a751407728dd67ef8d619fcf10bace527bcfc4e8d74b596e698e767317
7
+ data.tar.gz: a06663d9bb75f8bb9e3fe74e39bf6b3de31bc9d65ec7723fa12fa2e7fb37e1162291bdbc696ebcb1a2e19b632dd7c7e6aed4570758107d6fffeb7f1fe8268622
data/MIT-LICENSE CHANGED
@@ -1,4 +1,4 @@
1
- Copyright 2016 Mathías Montossi
1
+ Copyright 2017 Museways
2
2
 
3
3
  Permission is hereby granted, free of charge, to any person obtaining
4
4
  a copy of this software and associated documentation files (the
data/README.md CHANGED
@@ -1,7 +1,7 @@
1
1
  [![Gem Version](https://badge.fury.io/rb/indexers.svg)](http://badge.fury.io/rb/indexers)
2
- [![Code Climate](https://codeclimate.com/github/mmontossi/indexers/badges/gpa.svg)](https://codeclimate.com/github/mmontossi/indexers)
3
- [![Build Status](https://travis-ci.org/mmontossi/indexers.svg)](https://travis-ci.org/mmontossi/indexers)
4
- [![Dependency Status](https://gemnasium.com/mmontossi/indexers.svg)](https://gemnasium.com/mmontossi/indexers)
2
+ [![Code Climate](https://codeclimate.com/github/museways/indexers/badges/gpa.svg)](https://codeclimate.com/github/museways/indexers)
3
+ [![Build Status](https://travis-ci.org/museways/indexers.svg)](https://travis-ci.org/museways/indexers)
4
+ [![Dependency Status](https://gemnasium.com/museways/indexers.svg)](https://gemnasium.com/museways/indexers)
5
5
 
6
6
  # Indexers
7
7
 
@@ -31,10 +31,10 @@ $ bundle
31
31
 
32
32
  To install Redis you can use homebrew:
33
33
  ```
34
- $ brew install elasticsearch24
34
+ $ brew install elasticsearch
35
35
  ```
36
36
 
37
- NOTE: This gem is tested agains version 2.4.
37
+ NOTE: This gem is tested agains version 5.4.
38
38
 
39
39
  ## Configuration
40
40
 
@@ -52,8 +52,7 @@ Indexers.configure do |config|
52
52
  type 'string'
53
53
  fields do
54
54
  raw do
55
- type 'string'
56
- index 'not_analyzed'
55
+ type 'keyword'
57
56
  end
58
57
  end
59
58
  end
@@ -69,7 +68,7 @@ Indexers.configure do |config|
69
68
  end
70
69
  ```
71
70
 
72
- If you need to personalize the analysis, you can it here:
71
+ If you need to personalize the analysis:
73
72
 
74
73
  ```ruby
75
74
  Indexers.configure do |config|
@@ -115,7 +114,6 @@ Indexers.define :product do
115
114
  extract record, :name, :category, :price
116
115
  product_suggestions do
117
116
  input [record.name, transliterate(record.name)].uniq
118
- output record.name
119
117
  end
120
118
  end
121
119
 
@@ -149,9 +147,8 @@ Indexers.define :product do
149
147
  shop = options[:shop]
150
148
  term = args.first
151
149
  query do
152
- filtered do
153
- traits :shop
154
- query do
150
+ bool do
151
+ must do
155
152
  if term.present?
156
153
  multi_match do
157
154
  query term
@@ -162,19 +159,16 @@ Indexers.define :product do
162
159
  match_all
163
160
  end
164
161
  end
162
+ traits :shop
165
163
  end
166
164
  end
167
165
  end
168
166
 
169
167
  trait :shop do
170
168
  filter do
171
- bool do
172
- must do
173
- if shop
174
- term do
175
- _parent shop.id
176
- end
177
- end
169
+ if shop
170
+ term do
171
+ _parent shop.id
178
172
  end
179
173
  end
180
174
  end
@@ -229,7 +223,7 @@ Product.search.includes(:shop)
229
223
 
230
224
  ### Pagination
231
225
 
232
- Works the same as [pagers gem](https://github.com/mmontossi/pagers):
226
+ Works the same as [pagers gem](https://github.com/museways/pagers):
233
227
  ```ruby
234
228
  Products.search.page(1, padding: 4, length: 30)
235
229
  ```
@@ -263,7 +257,7 @@ Indexers.configure do |config|
263
257
  config.computed_sort :price do |direction|
264
258
  type 'number'
265
259
  script do
266
- inline "if (_source.currency == 'UYU') { doc['price'].value * 30 }"
260
+ inline "if (params['_source']['currency'] == 'UYU') { doc['price'].value * 30 }"
267
261
  end
268
262
  order direction
269
263
  end
@@ -302,11 +296,11 @@ The result is an array of hashes with a text property:
302
296
 
303
297
  Any issue, pull request, comment of any kind is more than welcome!
304
298
 
305
- I will mainly ensure compatibility to PostgreSQL, AWS, Redis, Elasticsearch, FreeBSD and Memcached
299
+ I will mainly ensure compatibility to Rails, AWS, PostgreSQL, Redis, Elasticsearch and FreeBSD
306
300
 
307
301
  ## Credits
308
302
 
309
- This gem is maintained and funded by [mmontossi](https://github.com/mmontossi).
303
+ This gem is maintained and funded by [museways](https://github.com/museways).
310
304
 
311
305
  ## License
312
306
 
data/Rakefile CHANGED
@@ -4,16 +4,14 @@ rescue LoadError
4
4
  puts 'You must `gem install bundler` and `bundle install` to run rake tasks'
5
5
  end
6
6
 
7
- Bundler::GemHelper.install_tasks
7
+ require 'bundler/gem_tasks'
8
8
 
9
9
  require 'rake/testtask'
10
10
 
11
11
  Rake::TestTask.new(:test) do |t|
12
- t.libs << 'lib'
13
12
  t.libs << 'test'
14
13
  t.pattern = 'test/**/*_test.rb'
15
14
  t.verbose = false
16
- t.warning = false
17
15
  end
18
16
 
19
17
  task default: :test
data/lib/indexers.rb CHANGED
@@ -19,7 +19,7 @@ module Indexers
19
19
  class << self
20
20
 
21
21
  def namespace
22
- "#{Rails.application.class.parent_name} #{Rails.env}".parameterize('_')
22
+ "#{Rails.application.class.parent_name} #{Rails.env}".parameterize(separator: '_')
23
23
  end
24
24
 
25
25
  def client
@@ -56,7 +56,7 @@ module Indexers
56
56
  values << { _script: Dsl::Api.new(direction, &block).to_h }
57
57
  elsif property == :id
58
58
  values << { _uid: { order: direction } }
59
- elsif mappings.has_key?(property) && mappings[property][:type] == 'string'
59
+ elsif mappings.has_key?(property) && mappings[property][:type] == 'text'
60
60
  values << { "#{property}.raw" => { order: direction } }
61
61
  end
62
62
  end
@@ -84,19 +84,17 @@ module Indexers
84
84
  request = Dsl::Search.new do
85
85
  if without_ids.any?
86
86
  query do
87
- filtered do
88
- filter do
89
- bool do
90
- must_not do
91
- without_ids.each do |id|
92
- term do
93
- _id id
94
- end
95
- end
87
+ bool do
88
+ must do
89
+ body
90
+ end
91
+ must_not do
92
+ without_ids.each do |id|
93
+ term do
94
+ _id id
96
95
  end
97
96
  end
98
97
  end
99
- query body
100
98
  end
101
99
  end
102
100
  else
@@ -155,7 +153,7 @@ module Indexers
155
153
 
156
154
  def fetch_ids(source)
157
155
  case source
158
- when Fixnum,String
156
+ when Integer,String
159
157
  [source.to_i]
160
158
  when ActiveRecord::Base
161
159
  [source.id]
@@ -22,7 +22,7 @@ module Indexers
22
22
  end
23
23
 
24
24
  def indexer
25
- @indexer ||= Indexers.definitions.find(name.parameterize('_').to_sym)
25
+ @indexer ||= Indexers.definitions.find(name.parameterize(separator: '_').to_sym)
26
26
  end
27
27
 
28
28
  end
@@ -1,5 +1,5 @@
1
1
  module Indexers
2
2
 
3
- VERSION = '4.1.0.1'
3
+ VERSION = '5.1.0'
4
4
 
5
5
  end
metadata CHANGED
@@ -1,80 +1,74 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: indexers
3
3
  version: !ruby/object:Gem::Version
4
- version: 4.1.0.1
4
+ version: 5.1.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - mmontossi
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2016-12-14 00:00:00.000000000 Z
11
+ date: 2017-09-27 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rails
15
15
  requirement: !ruby/object:Gem::Requirement
16
16
  requirements:
17
- - - ">="
18
- - !ruby/object:Gem::Version
19
- version: 4.2.0
20
- - - "<"
17
+ - - "~>"
21
18
  - !ruby/object:Gem::Version
22
- version: 4.3.0
19
+ version: '5.1'
23
20
  type: :runtime
24
21
  prerelease: false
25
22
  version_requirements: !ruby/object:Gem::Requirement
26
23
  requirements:
27
- - - ">="
28
- - !ruby/object:Gem::Version
29
- version: 4.2.0
30
- - - "<"
24
+ - - "~>"
31
25
  - !ruby/object:Gem::Version
32
- version: 4.3.0
26
+ version: '5.1'
33
27
  - !ruby/object:Gem::Dependency
34
28
  name: elasticsearch
35
29
  requirement: !ruby/object:Gem::Requirement
36
30
  requirements:
37
31
  - - "~>"
38
32
  - !ruby/object:Gem::Version
39
- version: 2.0.0
33
+ version: '5.0'
40
34
  type: :runtime
41
35
  prerelease: false
42
36
  version_requirements: !ruby/object:Gem::Requirement
43
37
  requirements:
44
38
  - - "~>"
45
39
  - !ruby/object:Gem::Version
46
- version: 2.0.0
40
+ version: '5.0'
47
41
  - !ruby/object:Gem::Dependency
48
42
  name: pg
49
43
  requirement: !ruby/object:Gem::Requirement
50
44
  requirements:
51
45
  - - "~>"
52
46
  - !ruby/object:Gem::Version
53
- version: '0.18'
47
+ version: '0.21'
54
48
  type: :development
55
49
  prerelease: false
56
50
  version_requirements: !ruby/object:Gem::Requirement
57
51
  requirements:
58
52
  - - "~>"
59
53
  - !ruby/object:Gem::Version
60
- version: '0.18'
54
+ version: '0.21'
61
55
  - !ruby/object:Gem::Dependency
62
56
  name: mocha
63
57
  requirement: !ruby/object:Gem::Requirement
64
58
  requirements:
65
59
  - - "~>"
66
60
  - !ruby/object:Gem::Version
67
- version: '1.1'
61
+ version: '1.2'
68
62
  type: :development
69
63
  prerelease: false
70
64
  version_requirements: !ruby/object:Gem::Requirement
71
65
  requirements:
72
66
  - - "~>"
73
67
  - !ruby/object:Gem::Version
74
- version: '1.1'
68
+ version: '1.2'
75
69
  description: Dsl to delegate searches to elasticsearch in rails.
76
70
  email:
77
- - mmontossi@gmail.com
71
+ - hi@museways.com
78
72
  executables: []
79
73
  extensions: []
80
74
  extra_rdoc_files: []
@@ -105,59 +99,7 @@ files:
105
99
  - lib/indexers/railtie.rb
106
100
  - lib/indexers/version.rb
107
101
  - lib/tasks/indexers.rake
108
- - test/dsl_test.rb
109
- - test/dummy/Rakefile
110
- - test/dummy/app/assets/javascripts/application.js
111
- - test/dummy/app/assets/stylesheets/application.css
112
- - test/dummy/app/controllers/application_controller.rb
113
- - test/dummy/app/helpers/application_helper.rb
114
- - test/dummy/app/indexers/product_indexer.rb
115
- - test/dummy/app/indexers/shop_indexer.rb
116
- - test/dummy/app/models/product.rb
117
- - test/dummy/app/models/shop.rb
118
- - test/dummy/app/views/layouts/application.html.erb
119
- - test/dummy/bin/bundle
120
- - test/dummy/bin/rails
121
- - test/dummy/bin/rake
122
- - test/dummy/bin/setup
123
- - test/dummy/config.ru
124
- - test/dummy/config/application.rb
125
- - test/dummy/config/boot.rb
126
- - test/dummy/config/database.yml
127
- - test/dummy/config/database.yml.travis
128
- - test/dummy/config/elasticsearch.yml
129
- - test/dummy/config/environment.rb
130
- - test/dummy/config/environments/development.rb
131
- - test/dummy/config/environments/production.rb
132
- - test/dummy/config/environments/test.rb
133
- - test/dummy/config/initializers/assets.rb
134
- - test/dummy/config/initializers/backtrace_silencers.rb
135
- - test/dummy/config/initializers/cookies_serializer.rb
136
- - test/dummy/config/initializers/filter_parameter_logging.rb
137
- - test/dummy/config/initializers/indexers.rb
138
- - test/dummy/config/initializers/inflections.rb
139
- - test/dummy/config/initializers/mime_types.rb
140
- - test/dummy/config/initializers/session_store.rb
141
- - test/dummy/config/initializers/wrap_parameters.rb
142
- - test/dummy/config/locales/en.yml
143
- - test/dummy/config/routes.rb
144
- - test/dummy/config/secrets.yml
145
- - test/dummy/db/migrate/20161104164148_create_products.rb
146
- - test/dummy/db/migrate/20161104182219_create_shops.rb
147
- - test/dummy/db/schema.rb
148
- - test/dummy/log/development.log
149
- - test/dummy/log/test.log
150
- - test/dummy/public/404.html
151
- - test/dummy/public/422.html
152
- - test/dummy/public/500.html
153
- - test/dummy/public/favicon.ico
154
- - test/generator_test.rb
155
- - test/index_test.rb
156
- - test/record_test.rb
157
- - test/search_test.rb
158
- - test/task_test.rb
159
- - test/test_helper.rb
160
- homepage: https://github.com/mmontossi/indexers
102
+ homepage: https://github.com/museways/indexers
161
103
  licenses:
162
104
  - MIT
163
105
  metadata: {}
@@ -169,69 +111,16 @@ required_ruby_version: !ruby/object:Gem::Requirement
169
111
  requirements:
170
112
  - - ">="
171
113
  - !ruby/object:Gem::Version
172
- version: 2.0.0
114
+ version: '0'
173
115
  required_rubygems_version: !ruby/object:Gem::Requirement
174
116
  requirements:
175
117
  - - ">="
176
118
  - !ruby/object:Gem::Version
177
119
  version: '0'
178
- requirements:
179
- - Elasticsearch
120
+ requirements: []
180
121
  rubyforge_project:
181
- rubygems_version: 2.5.1
122
+ rubygems_version: 2.6.13
182
123
  signing_key:
183
124
  specification_version: 4
184
125
  summary: Search indexers for rails.
185
- test_files:
186
- - test/dsl_test.rb
187
- - test/dummy/app/assets/javascripts/application.js
188
- - test/dummy/app/assets/stylesheets/application.css
189
- - test/dummy/app/controllers/application_controller.rb
190
- - test/dummy/app/helpers/application_helper.rb
191
- - test/dummy/app/indexers/product_indexer.rb
192
- - test/dummy/app/indexers/shop_indexer.rb
193
- - test/dummy/app/models/product.rb
194
- - test/dummy/app/models/shop.rb
195
- - test/dummy/app/views/layouts/application.html.erb
196
- - test/dummy/bin/bundle
197
- - test/dummy/bin/rails
198
- - test/dummy/bin/rake
199
- - test/dummy/bin/setup
200
- - test/dummy/config/application.rb
201
- - test/dummy/config/boot.rb
202
- - test/dummy/config/database.yml
203
- - test/dummy/config/database.yml.travis
204
- - test/dummy/config/elasticsearch.yml
205
- - test/dummy/config/environment.rb
206
- - test/dummy/config/environments/development.rb
207
- - test/dummy/config/environments/production.rb
208
- - test/dummy/config/environments/test.rb
209
- - test/dummy/config/initializers/assets.rb
210
- - test/dummy/config/initializers/backtrace_silencers.rb
211
- - test/dummy/config/initializers/cookies_serializer.rb
212
- - test/dummy/config/initializers/filter_parameter_logging.rb
213
- - test/dummy/config/initializers/indexers.rb
214
- - test/dummy/config/initializers/inflections.rb
215
- - test/dummy/config/initializers/mime_types.rb
216
- - test/dummy/config/initializers/session_store.rb
217
- - test/dummy/config/initializers/wrap_parameters.rb
218
- - test/dummy/config/locales/en.yml
219
- - test/dummy/config/routes.rb
220
- - test/dummy/config/secrets.yml
221
- - test/dummy/config.ru
222
- - test/dummy/db/migrate/20161104164148_create_products.rb
223
- - test/dummy/db/migrate/20161104182219_create_shops.rb
224
- - test/dummy/db/schema.rb
225
- - test/dummy/log/development.log
226
- - test/dummy/log/test.log
227
- - test/dummy/public/404.html
228
- - test/dummy/public/422.html
229
- - test/dummy/public/500.html
230
- - test/dummy/public/favicon.ico
231
- - test/dummy/Rakefile
232
- - test/generator_test.rb
233
- - test/index_test.rb
234
- - test/record_test.rb
235
- - test/search_test.rb
236
- - test/task_test.rb
237
- - test/test_helper.rb
126
+ test_files: []