sequel-elasticsearch 0.4.9 → 0.4.10
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/sequel/plugins/elasticsearch/version.rb +1 -1
- data/lib/sequel/plugins/elasticsearch.rb +6 -29
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 127744853b0d25416671270e0c75376721284923f3b3194a2304c819f0571e06
|
4
|
+
data.tar.gz: 2aa0e317aa39975bcf71fa5c50d759fd9acc448551af6165be298a97280f066b
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 4fa15223dff93ee23bc8ec8a1c42d02db514e4888514a2aa049fc1e118f4f5565f2a18e73ad0bc21da0ba08c98926f3005ff02b81467ec111d8fcb3dcca75f04
|
7
|
+
data.tar.gz: 50ff3ef8237090863eb7d62d83ddb79477e32b95ebe0458bda0abf1bd4c0b73c90887aafe5be9bb4035294900a0ff04e58e244d3d1e3aba1b68ed4218874a91f
|
@@ -21,16 +21,9 @@ module Sequel
|
|
21
21
|
|
22
22
|
# Configure the plugin
|
23
23
|
def self.configure(model, opts = OPTS)
|
24
|
-
environment_scoped = if opts[:environment_scoped].nil?
|
25
|
-
model.environment != 'test'
|
26
|
-
else
|
27
|
-
opts[:environment_scoped]
|
28
|
-
end
|
29
|
-
|
30
24
|
model.elasticsearch_opts = opts[:elasticsearch] || {}
|
31
25
|
model.elasticsearch_index = (opts[:index] || model.table_name).to_sym
|
32
26
|
model.elasticsearch_type = (opts[:type] || :_doc).to_sym
|
33
|
-
model.elasticsearch_environment_scoped = environment_scoped
|
34
27
|
model
|
35
28
|
end
|
36
29
|
|
@@ -39,11 +32,9 @@ module Sequel
|
|
39
32
|
# The extra options that will be passed to the Elasticsearch client.
|
40
33
|
attr_accessor :elasticsearch_opts
|
41
34
|
# The Elasticsearch index to which the documents will be written.
|
42
|
-
|
35
|
+
attr_accessor :elasticsearch_index
|
43
36
|
# The Elasticsearch type to which the documents will be written.
|
44
37
|
attr_accessor :elasticsearch_type
|
45
|
-
# If generated indices should include the environment name
|
46
|
-
attr_accessor :elasticsearch_environment_scoped
|
47
38
|
|
48
39
|
# Return the Elasticsearch client used to communicate with the cluster.
|
49
40
|
def es_client
|
@@ -129,6 +120,7 @@ module Sequel
|
|
129
120
|
alias_index(index_name)
|
130
121
|
end
|
131
122
|
|
123
|
+
# Remove previous aliases and point the `elasticsearch_index` to the new index.
|
132
124
|
def alias_index(new_index)
|
133
125
|
es_client.indices.update_aliases body: {
|
134
126
|
actions: [
|
@@ -143,29 +135,14 @@ module Sequel
|
|
143
135
|
es_client.indices.get_alias(name: elasticsearch_index)&.keys&.sort&.first
|
144
136
|
end
|
145
137
|
|
146
|
-
|
147
|
-
|
148
|
-
|
149
|
-
"#{@elasticsearch_index}-#{environment}".to_sym
|
150
|
-
end
|
151
|
-
|
152
|
-
# Generate a timestamped index name according to the environment.
|
153
|
-
# This will use the +APP_ENV+ or +RACK_ENV+ ENV variable and a timestamp
|
154
|
-
# to construct index names like this:
|
155
|
-
#
|
156
|
-
# base-name-staging-20191004.123456 # This is a staging index
|
157
|
-
# base-name-production-20191005.171213 # This is a production index
|
138
|
+
# Generate a timestamped index name.
|
139
|
+
# This will use the current timestamp to construct index names like this:
|
158
140
|
#
|
159
|
-
#
|
160
|
-
# setting +elasticsearch_environment_scoped+ to false.
|
141
|
+
# base-name-20191004.123456
|
161
142
|
def timestamped_index
|
162
|
-
time_str = Time.now.strftime('%Y%m%d.%H%M%S')
|
143
|
+
time_str = Time.now.strftime('%Y%m%d.%H%M%S') # TODO: Make the format configurable
|
163
144
|
"#{elasticsearch_index}-#{time_str}".to_sym
|
164
145
|
end
|
165
|
-
|
166
|
-
def environment
|
167
|
-
ENV['APP_ENV'] || ENV['RACK_ENV'] || 'development'
|
168
|
-
end
|
169
146
|
end
|
170
147
|
|
171
148
|
# The instance methods that will be added to the Sequel::Model
|
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.10
|
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
|
+
date: 2019-11-11 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: elasticsearch
|