sequel-elasticsearch 0.4.0 → 0.4.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/.travis.yml +4 -3
- data/lib/sequel/plugins/elasticsearch/version.rb +4 -1
- data/lib/sequel/plugins/elasticsearch.rb +35 -19
- metadata +3 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 2a43685e46f98064dabf222a2145e4248bb02415e6a3fa3d664b7314c1b17e5f
|
4
|
+
data.tar.gz: 2356dfe5cd6efe4d97e5ac177c55bfd6362e14f803816b3ae8b81db87c859c9e
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 99de7a66cf051b722ba2da36200c591c680c1a78fcbeeebbc8c6572974bf5638fe908c9a7dc61e287cd6cf57664a44ddad4e56fdd421bebd268136cf689c22c4
|
7
|
+
data.tar.gz: f03ae3900ac8b2d72b2c4b4d153df0d252ffd3c399d104fe2d3d1e3ff32299bc2df190321fe850ef47a7d542711bb72e4af0281fd087e18dddc510baec751766
|
data/.travis.yml
CHANGED
@@ -1,9 +1,9 @@
|
|
1
1
|
sudo: false
|
2
2
|
language: ruby
|
3
3
|
rvm:
|
4
|
-
- 2.3.
|
5
|
-
- 2.4.
|
6
|
-
- 2.5.
|
4
|
+
- 2.3.7
|
5
|
+
- 2.4.4
|
6
|
+
- 2.5.1
|
7
7
|
gemfile: Gemfile.ci
|
8
8
|
env:
|
9
9
|
global:
|
@@ -15,6 +15,7 @@ before_script:
|
|
15
15
|
> ./cc-test-reporter
|
16
16
|
- chmod +x ./cc-test-reporter
|
17
17
|
- "./cc-test-reporter before-build"
|
18
|
+
- export TZ=Africa/Johannesburg
|
18
19
|
after_script:
|
19
20
|
- "./cc-test-reporter after-build --exit-code $TRAVIS_TEST_RESULT"
|
20
21
|
deploy:
|
@@ -1,7 +1,9 @@
|
|
1
1
|
require 'elasticsearch'
|
2
2
|
require 'sequel/plugins/elasticsearch/result'
|
3
3
|
|
4
|
+
# Sequel: The Database Toolkit for Ruby
|
4
5
|
module Sequel
|
6
|
+
# Sequel Plugins - http://sequel.jeremyevans.net/plugins.html
|
5
7
|
module Plugins
|
6
8
|
# The Sequel::Elasticsearch model plugin
|
7
9
|
#
|
@@ -56,6 +58,7 @@ module Sequel
|
|
56
58
|
def scroll!(scroll_id, duration)
|
57
59
|
scroll_id = scroll_id.scroll_id if scroll_id.is_a? Result
|
58
60
|
return nil unless scroll_id
|
61
|
+
|
59
62
|
Result.new es_client.scroll(scroll_id: scroll_id, scroll: duration), self
|
60
63
|
end
|
61
64
|
|
@@ -68,13 +71,16 @@ module Sequel
|
|
68
71
|
# Wrapper method in which error handling is done for Elasticsearch calls.
|
69
72
|
def call_es
|
70
73
|
yield
|
71
|
-
rescue ::Elasticsearch::Transport::Transport::Errors::NotFound,
|
72
|
-
|
73
|
-
|
74
|
-
rescue Faraday::ConnectionFailed => e
|
74
|
+
rescue ::Elasticsearch::Transport::Transport::Errors::NotFound,
|
75
|
+
::Elasticsearch::Transport::Transport::Error,
|
76
|
+
Faraday::ConnectionFailed => e
|
75
77
|
db.loggers.first.warn e if db.loggers.count.positive?
|
76
78
|
nil
|
77
79
|
end
|
80
|
+
|
81
|
+
# Import the whole dataset into Elasticsearch
|
82
|
+
def import!
|
83
|
+
end
|
78
84
|
end
|
79
85
|
|
80
86
|
# The instance methods that will be added to the Sequel::Model
|
@@ -105,14 +111,20 @@ module Sequel
|
|
105
111
|
self.class.es_client
|
106
112
|
end
|
107
113
|
|
108
|
-
|
114
|
+
def as_indexed_json
|
115
|
+
indexed_values
|
116
|
+
end
|
109
117
|
|
110
|
-
#
|
111
|
-
|
112
|
-
|
113
|
-
|
114
|
-
|
115
|
-
|
118
|
+
# Create or update the document on the Elasticsearch cluster.
|
119
|
+
def index_document
|
120
|
+
params = document_path
|
121
|
+
params[:body] = indexed_values
|
122
|
+
es_client.index params
|
123
|
+
end
|
124
|
+
|
125
|
+
# Remove the document from the Elasticsearch cluster.
|
126
|
+
def destroy_document
|
127
|
+
es_client.delete document_path
|
116
128
|
end
|
117
129
|
|
118
130
|
# Determine the complete path to a document (/index/type/id) in the Elasticsearch cluster.
|
@@ -124,16 +136,20 @@ module Sequel
|
|
124
136
|
}
|
125
137
|
end
|
126
138
|
|
127
|
-
|
128
|
-
|
129
|
-
|
130
|
-
|
131
|
-
|
139
|
+
private
|
140
|
+
|
141
|
+
# Determine the ID to be used for the document in the Elasticsearch cluster.
|
142
|
+
# It will join the values of a multi field primary key with an underscore.
|
143
|
+
def document_id
|
144
|
+
doc_id = pk
|
145
|
+
doc_id = doc_id.join('_') if doc_id.is_a? Array
|
146
|
+
doc_id
|
132
147
|
end
|
133
148
|
|
134
|
-
#
|
135
|
-
def
|
136
|
-
|
149
|
+
# Values to be indexed
|
150
|
+
def indexed_values
|
151
|
+
# TODO: Deprecate this method in favour of as_indexed_json
|
152
|
+
values.each_key { |k| values[k] = values[k].strftime('%FT%T%:z') if values[k].is_a?(Time) }
|
137
153
|
end
|
138
154
|
end
|
139
155
|
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.3
|
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: 2018-
|
11
|
+
date: 2018-10-17 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: elasticsearch
|
@@ -164,7 +164,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
164
164
|
version: '0'
|
165
165
|
requirements: []
|
166
166
|
rubyforge_project:
|
167
|
-
rubygems_version: 2.7.
|
167
|
+
rubygems_version: 2.7.7
|
168
168
|
signing_key:
|
169
169
|
specification_version: 4
|
170
170
|
summary: A plugin for the Sequel gem to sync data to Elasticsearch.
|