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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 4b72432bc6c37b866fb0959c07d71b0bb90fa8773ad0006fe65250f62e80b48e
4
- data.tar.gz: 7eb98c377331877a870449a1e3c1060504c70eb6e7f7cc9905a0ad767406090e
3
+ metadata.gz: 2a43685e46f98064dabf222a2145e4248bb02415e6a3fa3d664b7314c1b17e5f
4
+ data.tar.gz: 2356dfe5cd6efe4d97e5ac177c55bfd6362e14f803816b3ae8b81db87c859c9e
5
5
  SHA512:
6
- metadata.gz: 1de1abc8e613aeaea8f256626b5f20c370e91f8bad909be2b9c76988a08868aed16caab5c10066fe70098984c49bf0c280e10398957d3b277fcf7a36c39c1297
7
- data.tar.gz: 40005b30e9552ceed6e2d560e843eeec2666f9dd444c36007581a59bc4a6ab94d293172502daf5ed3068cb8229b6673318182c66fed1d841a40c695c37b4b62e
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.6
5
- - 2.4.3
6
- - 2.5.0
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,6 +1,9 @@
1
1
  module Sequel
2
+ # The Sequel::Elasticsearch model plugin
3
+ #
4
+ # See https://jrgns.github.io/sequel-elasticsearch
2
5
  module Elasticsearch
3
6
  # The Gem's version.
4
- VERSION = '0.4.0'.freeze
7
+ VERSION = '0.4.3'.freeze
5
8
  end
6
9
  end
@@ -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, ::Elasticsearch::Transport::Transport::Error => e
72
- db.loggers.first.warn e if db.loggers.count.positive?
73
- nil
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
- private
114
+ def as_indexed_json
115
+ indexed_values
116
+ end
109
117
 
110
- # Determine the ID to be used for the document in the Elasticsearch cluster.
111
- # It will join the values of a multi field primary key with an underscore.
112
- def document_id
113
- doc_id = pk
114
- doc_id = doc_id.join('_') if doc_id.is_a? Array
115
- doc_id
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
- # Create or update the document on the Elasticsearch cluster.
128
- def index_document
129
- params = document_path
130
- params[:body] = values.each_key { |k| values[k] = values[k].strftime('%FT%T%:z') if values[k].is_a?(Time) }
131
- es_client.index params
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
- # Remove the document from the Elasticsearch cluster.
135
- def destroy_document
136
- es_client.delete document_path
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.0
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-02-09 00:00:00.000000000 Z
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.5
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.