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 +4 -4
- data/Gemfile +2 -0
- data/Rakefile +2 -0
- data/lib/sequel/plugins/elasticsearch.rb +10 -4
- data/lib/sequel/plugins/elasticsearch/result.rb +2 -0
- data/lib/sequel/plugins/elasticsearch/version.rb +3 -1
- data/sequel-elasticsearch.gemspec +5 -3
- metadata +24 -10
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: fcdb91c1414f1bad3b6ea789f58e96c7972c4581d8777769c9c5a93133afd578
|
4
|
+
data.tar.gz: '0599e138dc94ad85b12701dbd3df905838adaf4b2e0393e975956ce5aee095a4'
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 6a50a93c261b7a462a848a80db8d27a65dc3ac72ad16b5f372278b75b52adbaf9d36193d35d7ec169bccf66d296ce7a09f18f23233a7aaedd96e97ae79d93988
|
7
|
+
data.tar.gz: 918f315cb32de7564c2fa9cb5aad8a97401d95365b7af2a87e08df6c25c7893b101af95539764fef8ea3908d02e997038ba9005d78ec3fb97df78688b625770b
|
data/Gemfile
CHANGED
data/Rakefile
CHANGED
@@ -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.
|
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] =
|
203
|
+
params[:body] = as_indexed_json
|
198
204
|
es_client.index params
|
199
205
|
end
|
200
206
|
|
@@ -1,5 +1,6 @@
|
|
1
|
+
# frozen_string_literal: true
|
1
2
|
|
2
|
-
lib = File.expand_path('
|
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', '
|
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.
|
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
|
+
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:
|
126
|
+
name: sqlite3
|
113
127
|
requirement: !ruby/object:Gem::Requirement
|
114
128
|
requirements:
|
115
129
|
- - "~>"
|
116
130
|
- !ruby/object:Gem::Version
|
117
|
-
version: '
|
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: '
|
138
|
+
version: '1.4'
|
125
139
|
- !ruby/object:Gem::Dependency
|
126
|
-
name:
|
140
|
+
name: webmock
|
127
141
|
requirement: !ruby/object:Gem::Requirement
|
128
142
|
requirements:
|
129
143
|
- - "~>"
|
130
144
|
- !ruby/object:Gem::Version
|
131
|
-
version: '
|
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: '
|
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
|