sequel-elasticsearch 0.4.10 → 0.4.11

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 127744853b0d25416671270e0c75376721284923f3b3194a2304c819f0571e06
4
- data.tar.gz: 2aa0e317aa39975bcf71fa5c50d759fd9acc448551af6165be298a97280f066b
3
+ metadata.gz: fcdb91c1414f1bad3b6ea789f58e96c7972c4581d8777769c9c5a93133afd578
4
+ data.tar.gz: '0599e138dc94ad85b12701dbd3df905838adaf4b2e0393e975956ce5aee095a4'
5
5
  SHA512:
6
- metadata.gz: 4fa15223dff93ee23bc8ec8a1c42d02db514e4888514a2aa049fc1e118f4f5565f2a18e73ad0bc21da0ba08c98926f3005ff02b81467ec111d8fcb3dcca75f04
7
- data.tar.gz: 50ff3ef8237090863eb7d62d83ddb79477e32b95ebe0458bda0abf1bd4c0b73c90887aafe5be9bb4035294900a0ff04e58e244d3d1e3aba1b68ed4218874a91f
6
+ metadata.gz: 6a50a93c261b7a462a848a80db8d27a65dc3ac72ad16b5f372278b75b52adbaf9d36193d35d7ec169bccf66d296ce7a09f18f23233a7aaedd96e97ae79d93988
7
+ data.tar.gz: 918f315cb32de7564c2fa9cb5aad8a97401d95365b7af2a87e08df6c25c7893b101af95539764fef8ea3908d02e997038ba9005d78ec3fb97df78688b625770b
data/Gemfile CHANGED
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  source 'https://rubygems.org'
2
4
 
3
5
  # Specify your gem's dependencies in sequel-elasticsearch.gemspec
data/Rakefile CHANGED
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  libdir = File.expand_path(File.dirname(__FILE__) + '/lib')
2
4
  $LOAD_PATH.unshift(libdir) unless $LOAD_PATH.include?(libdir)
3
5
 
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require 'elasticsearch'
2
4
  require 'sequel/plugins/elasticsearch/result'
3
5
 
@@ -22,7 +24,7 @@ module Sequel
22
24
  # Configure the plugin
23
25
  def self.configure(model, opts = OPTS)
24
26
  model.elasticsearch_opts = opts[:elasticsearch] || {}
25
- model.elasticsearch_index = (opts[:index] || model.table_name).to_sym
27
+ model.elasticsearch_index = (opts[:index] || model.table_name.to_s.downcase).to_sym
26
28
  model.elasticsearch_type = (opts[:type] || :_doc).to_sym
27
29
  model
28
30
  end
@@ -85,7 +87,7 @@ module Sequel
85
87
  # Use the +reindex!+ method to create a completely new index and alias.
86
88
  def import!(index: nil, dataset: nil, batch_size: 100)
87
89
  dataset ||= self.dataset
88
- index_name = index || last_index
90
+ index_name = index || last_index || elasticsearch_index
89
91
 
90
92
  # Index all the documents
91
93
  body = []
@@ -98,7 +100,7 @@ module Sequel
98
100
  _index: index_name,
99
101
  _type: elasticsearch_type,
100
102
  _id: row.document_id,
101
- data: { doc: row.indexed_values, doc_as_upsert: true }
103
+ data: { doc: row.as_indexed_json, doc_as_upsert: true }
102
104
  }
103
105
  }
104
106
  end
@@ -133,6 +135,8 @@ module Sequel
133
135
  # Find the last created index that matches the specified index name.
134
136
  def last_index
135
137
  es_client.indices.get_alias(name: elasticsearch_index)&.keys&.sort&.first
138
+ rescue ::Elasticsearch::Transport::Transport::Errors::NotFound
139
+ nil
136
140
  end
137
141
 
138
142
  # Generate a timestamped index name.
@@ -181,6 +185,8 @@ module Sequel
181
185
  self.class.es_client
182
186
  end
183
187
 
188
+ # Mirror the Elasticsearch Rails plugin. Use this to override what data
189
+ # is sent to Elasticsearch
184
190
  def as_indexed_json
185
191
  indexed_values
186
192
  end
@@ -194,7 +200,7 @@ module Sequel
194
200
  # Create or update the document on the Elasticsearch cluster.
195
201
  def index_document(opts = {})
196
202
  params = document_path(opts)
197
- params[:body] = indexed_values
203
+ params[:body] = as_indexed_json
198
204
  es_client.index params
199
205
  end
200
206
 
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module Sequel
2
4
  module Plugins
3
5
  module Elasticsearch
@@ -1,9 +1,11 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module Sequel
2
4
  # The Sequel::Elasticsearch model plugin
3
5
  #
4
6
  # See https://jrgns.github.io/sequel-elasticsearch
5
7
  module Elasticsearch
6
8
  # The Gem's version.
7
- VERSION = '0.4.10'.freeze
9
+ VERSION = '0.4.11'
8
10
  end
9
11
  end
@@ -1,5 +1,6 @@
1
+ # frozen_string_literal: true
1
2
 
2
- lib = File.expand_path('../lib', __FILE__)
3
+ lib = File.expand_path('lib', __dir__)
3
4
  $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
5
  require 'sequel/plugins/elasticsearch/version'
5
6
 
@@ -27,8 +28,9 @@ Gem::Specification.new do |spec|
27
28
  spec.add_development_dependency 'bundler', '>= 1.13'
28
29
  spec.add_development_dependency 'rake', '~> 10.0'
29
30
  spec.add_development_dependency 'rspec', '~> 3.0'
30
- spec.add_development_dependency 'rubocop', '~> 0.52'
31
+ spec.add_development_dependency 'rubocop', '>= 0.52'
32
+ spec.add_development_dependency 'rubocop-rspec', '>= 1.37'
31
33
  spec.add_development_dependency 'simplecov', '~> 0.15'
32
- spec.add_development_dependency 'webmock', '~> 3.2'
33
34
  spec.add_development_dependency 'sqlite3', '~> 1.4'
35
+ spec.add_development_dependency 'webmock', '~> 3.2'
34
36
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: sequel-elasticsearch
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.4.10
4
+ version: 0.4.11
5
5
  platform: ruby
6
6
  authors:
7
7
  - Jurgens du Toit
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2019-11-11 00:00:00.000000000 Z
11
+ date: 2019-12-04 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: elasticsearch
@@ -84,16 +84,30 @@ dependencies:
84
84
  name: rubocop
85
85
  requirement: !ruby/object:Gem::Requirement
86
86
  requirements:
87
- - - "~>"
87
+ - - ">="
88
88
  - !ruby/object:Gem::Version
89
89
  version: '0.52'
90
90
  type: :development
91
91
  prerelease: false
92
92
  version_requirements: !ruby/object:Gem::Requirement
93
93
  requirements:
94
- - - "~>"
94
+ - - ">="
95
95
  - !ruby/object:Gem::Version
96
96
  version: '0.52'
97
+ - !ruby/object:Gem::Dependency
98
+ name: rubocop-rspec
99
+ requirement: !ruby/object:Gem::Requirement
100
+ requirements:
101
+ - - ">="
102
+ - !ruby/object:Gem::Version
103
+ version: '1.37'
104
+ type: :development
105
+ prerelease: false
106
+ version_requirements: !ruby/object:Gem::Requirement
107
+ requirements:
108
+ - - ">="
109
+ - !ruby/object:Gem::Version
110
+ version: '1.37'
97
111
  - !ruby/object:Gem::Dependency
98
112
  name: simplecov
99
113
  requirement: !ruby/object:Gem::Requirement
@@ -109,33 +123,33 @@ dependencies:
109
123
  - !ruby/object:Gem::Version
110
124
  version: '0.15'
111
125
  - !ruby/object:Gem::Dependency
112
- name: webmock
126
+ name: sqlite3
113
127
  requirement: !ruby/object:Gem::Requirement
114
128
  requirements:
115
129
  - - "~>"
116
130
  - !ruby/object:Gem::Version
117
- version: '3.2'
131
+ version: '1.4'
118
132
  type: :development
119
133
  prerelease: false
120
134
  version_requirements: !ruby/object:Gem::Requirement
121
135
  requirements:
122
136
  - - "~>"
123
137
  - !ruby/object:Gem::Version
124
- version: '3.2'
138
+ version: '1.4'
125
139
  - !ruby/object:Gem::Dependency
126
- name: sqlite3
140
+ name: webmock
127
141
  requirement: !ruby/object:Gem::Requirement
128
142
  requirements:
129
143
  - - "~>"
130
144
  - !ruby/object:Gem::Version
131
- version: '1.4'
145
+ version: '3.2'
132
146
  type: :development
133
147
  prerelease: false
134
148
  version_requirements: !ruby/object:Gem::Requirement
135
149
  requirements:
136
150
  - - "~>"
137
151
  - !ruby/object:Gem::Version
138
- version: '1.4'
152
+ version: '3.2'
139
153
  description: A plugin for the Sequel gem to sync data to Elasticsearch.
140
154
  email:
141
155
  - jrgns@jadeit.co.za