elasticsearch_record 1.5.0 → 1.5.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +14 -7
- data/docs/CHANGELOG.md +7 -0
- data/elasticsearch_record.gemspec +1 -0
- data/lib/active_record/connection_adapters/elasticsearch/schema_definitions/table_mapping_definition.rb +1 -1
- data/lib/elasticsearch_record/gem_version.rb +1 -1
- data/lib/elasticsearch_record/model_api.rb +80 -2
- data/lib/elasticsearch_record/relation/value_methods.rb +2 -2
- metadata +21 -7
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 9a53ead4edbffa7bb74c8021008343f80813512f89b6580717d7d4335ce238ba
|
4
|
+
data.tar.gz: 26603c0b2de3b938c4239401652d4986088be1d29b1c039c2feb0c48b83a5207
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 8d60b93db8b944ac6b0b42c91e411d6ae9673f773feeab7fbc9097e519663401a349936a271f6949d65f46485198cce44c349c38d3d2f668e2f3ee6148417264
|
7
|
+
data.tar.gz: 9e3a2700baa40c8bc4b6a72c6a94895f3beb030294955ca6d1a168349c81b289d80bf2d93cfa5411f0a8c2a74dd3b183ece5ee64ef3deef7ff2f0f440aef32dc
|
data/README.md
CHANGED
@@ -56,6 +56,7 @@ Or install it yourself as:
|
|
56
56
|
## Setup
|
57
57
|
|
58
58
|
### a) Update your **database.yml** and add a elasticsearch connection:
|
59
|
+
|
59
60
|
```yml
|
60
61
|
# config/database.yml
|
61
62
|
|
@@ -115,6 +116,7 @@ end
|
|
115
116
|
```
|
116
117
|
|
117
118
|
### c) Create a model that inherits from `ElasticsearchRecord::Base` model.
|
119
|
+
|
118
120
|
```ruby
|
119
121
|
# app/models/application_elasticsearch_record.rb
|
120
122
|
|
@@ -135,6 +137,7 @@ end
|
|
135
137
|
```
|
136
138
|
|
137
139
|
### d) have FUN with your model:
|
140
|
+
|
138
141
|
```ruby
|
139
142
|
scope = Search
|
140
143
|
.where(name: 'Custom Object Name')
|
@@ -155,12 +158,13 @@ scope.where(kind: :undefined).offset(10).update_all(name: "New Name")
|
|
155
158
|
|
156
159
|
## Active Record Query Interface
|
157
160
|
|
158
|
-
### Refactored
|
161
|
+
### Refactored `where` method:
|
159
162
|
Different to the default where-method you can now use it in different ways.
|
160
163
|
|
161
164
|
Using it by default with a Hash, the method decides itself to either add a filter, or must_not clause.
|
162
165
|
|
163
|
-
_Hint: If not provided through
|
166
|
+
_Hint: If not provided through `#kind`-method a default kind **:bool** will be used._
|
167
|
+
|
164
168
|
```ruby
|
165
169
|
# use it by default
|
166
170
|
Search.where(name: 'A nice object')
|
@@ -213,7 +217,6 @@ results_count = scope.count
|
|
213
217
|
# > 5
|
214
218
|
total = scope.total
|
215
219
|
# > 3335
|
216
|
-
|
217
220
|
```
|
218
221
|
|
219
222
|
### Available query/relation chain methods
|
@@ -322,7 +325,6 @@ Elasticsearch's default value for queries without a **size** is forced to **10**
|
|
322
325
|
To provide a similar behaviour as the (my)SQL interface,
|
323
326
|
this can be automatically set to the `max_result_window` value by calling `.limit(nil)` on the models' relation.
|
324
327
|
|
325
|
-
|
326
328
|
```ruby
|
327
329
|
SearchUser.where(name: 'Peter').limit(nil)
|
328
330
|
# returns a maximum of 10 items ...
|
@@ -335,6 +337,8 @@ SearchUser.where(name: 'Peter').limit(nil)
|
|
335
337
|
# returns up to 10_000 items ...
|
336
338
|
# => [...]
|
337
339
|
|
340
|
+
# hint: setting the 'max_result_window' can also be done by providing '__max__' wto the limit method: SearchUser.limit('__max__')
|
341
|
+
|
338
342
|
# hint: if you want more than 10_000 use the +#pit_results+ method!
|
339
343
|
```
|
340
344
|
|
@@ -350,6 +354,7 @@ SearchUser.where(name: 'Peter').limit(nil)
|
|
350
354
|
Quick access to model-related methods for easier access without creating a overcomplicated method call on the models connection...
|
351
355
|
|
352
356
|
Access these methods through the model class method `.api`.
|
357
|
+
|
353
358
|
```ruby
|
354
359
|
# returns mapping of model class
|
355
360
|
klass.api.mappings
|
@@ -523,7 +528,6 @@ class AddTests < ActiveRecord::Migration[7.0]
|
|
523
528
|
end
|
524
529
|
```
|
525
530
|
|
526
|
-
|
527
531
|
## environment-related-table-name:
|
528
532
|
Using the `_env_table_name`-method will resolve the table (index) name within the current environment,
|
529
533
|
even if the environments shares the same cluster ...
|
@@ -533,11 +537,14 @@ Within the migration the `_env_table_name`-method must be used in combination wi
|
|
533
537
|
|
534
538
|
**Example:**
|
535
539
|
Production uses a index suffix with '-pro', development uses '-dev' - they share the same cluster, but different indexes.
|
540
|
+
|
536
541
|
For the **settings** table:
|
537
|
-
|
538
|
-
|
542
|
+
|
543
|
+
* settings-pro
|
544
|
+
* settings-dev
|
539
545
|
|
540
546
|
A single migration can be created to be used within each environment:
|
547
|
+
|
541
548
|
```ruby
|
542
549
|
# Example migration
|
543
550
|
class AddSettings < ActiveRecord::Migration[7.0]
|
data/docs/CHANGELOG.md
CHANGED
@@ -1,5 +1,12 @@
|
|
1
1
|
# ElasticsearchRecord - CHANGELOG
|
2
2
|
|
3
|
+
## [1.5.2] - 2023-07-12
|
4
|
+
* [fix] `ElasticsearchRecord::Relation#limit` setter method `limit_value=` to work with **delegate_query_nil_limit?**
|
5
|
+
|
6
|
+
## [1.5.1] - 2023-07-11
|
7
|
+
* [fix] `ElasticsearchRecord::ModelApi` 'drop!' & 'truncate!' methods to support correct parameter 'confirm'
|
8
|
+
* [ref] improved yard documentation
|
9
|
+
|
3
10
|
## [1.5.0] - 2023-07-10
|
4
11
|
* [add] additional `ElasticsearchRecord::ModelApi` methods **drop!** & **truncate!**, which have to be called with a `confirm:true` parameter
|
5
12
|
* [add] `.ElasticsearchRecord::Base.delegate_query_nil_limit` to automatically delegate a relations `limit(nil)`-call to the **max_result_window** _(set to 10.000 as default)_
|
@@ -40,4 +40,5 @@ DESC
|
|
40
40
|
spec.add_development_dependency 'rake', "~> 13.0"
|
41
41
|
spec.add_development_dependency 'yard', '~> 0.9'
|
42
42
|
spec.add_development_dependency 'yard-activesupport-concern', '~> 0.0.1'
|
43
|
+
spec.add_development_dependency 'yard-relative_markdown_links', '>= 0.4'
|
43
44
|
end
|
@@ -33,8 +33,8 @@ module ElasticsearchRecord
|
|
33
33
|
# drop!(confirm: true)
|
34
34
|
# truncate!(confirm: true)
|
35
35
|
%w(drop truncate).each do |method|
|
36
|
-
define_method("#{method}!") do |
|
37
|
-
raise "#{method} of table '#{_index_name}' aborted!\nexecution not confirmed!\ncall with: #{klass}.api.#{method}!(
|
36
|
+
define_method("#{method}!") do |confirm: false|
|
37
|
+
raise "#{method} of table '#{_index_name}' aborted!\nexecution not confirmed!\ncall with: #{klass}.api.#{method}!(confirm: true)" unless confirm
|
38
38
|
_connection.send("#{method}_table", _index_name)
|
39
39
|
end
|
40
40
|
end
|
@@ -68,6 +68,84 @@ module ElasticsearchRecord
|
|
68
68
|
end
|
69
69
|
end
|
70
70
|
|
71
|
+
# -- DYNAMIC METHOD DOCUMENTATION FOR YARD -------------------------------------------------------------------------
|
72
|
+
|
73
|
+
# @!method open!
|
74
|
+
# Shortcut to open the closed index.
|
75
|
+
# @return [Boolean] acknowledged status
|
76
|
+
|
77
|
+
# @!method close!
|
78
|
+
# Shortcut to close the opened index.
|
79
|
+
# @return [Boolean] acknowledged status
|
80
|
+
|
81
|
+
# @!method refresh!
|
82
|
+
# Shortcut to refresh the index.
|
83
|
+
# @return [Boolean] result state (returns false if refreshing failed)
|
84
|
+
|
85
|
+
# @!method block!
|
86
|
+
# Shortcut to block write access on the index
|
87
|
+
# @return [Boolean] acknowledged status
|
88
|
+
|
89
|
+
# @!method unblock!
|
90
|
+
# Shortcut to unblock all blocked accesses on the index
|
91
|
+
# @return [Boolean] acknowledged status
|
92
|
+
|
93
|
+
# @!method drop!(confirm: false)
|
94
|
+
# Shortcut to drop the index
|
95
|
+
# @param confirm
|
96
|
+
# @return [Boolean] acknowledged status
|
97
|
+
|
98
|
+
# @!method truncate!(confirm: false)
|
99
|
+
# Shortcut to truncate the index
|
100
|
+
# @param confirm
|
101
|
+
# @return [Boolean] acknowledged status
|
102
|
+
|
103
|
+
# @!method mappings
|
104
|
+
# Shortcut for mappings
|
105
|
+
# @return [Hash]
|
106
|
+
|
107
|
+
# @!method metas
|
108
|
+
# Shortcut for metas
|
109
|
+
# @return [Hash]
|
110
|
+
|
111
|
+
# @!method settings(flat_settings=true)
|
112
|
+
# Shortcut for settings
|
113
|
+
# @param [Boolean] flat_settings (default: true)
|
114
|
+
# @return [Hash]
|
115
|
+
|
116
|
+
# @!method aliases
|
117
|
+
# Shortcut for aliases
|
118
|
+
# @return [Hash]
|
119
|
+
|
120
|
+
# @!method state
|
121
|
+
# Shortcut for state
|
122
|
+
# @return [Hash]
|
123
|
+
|
124
|
+
# @!method schema(features=[])
|
125
|
+
# Shortcut for schema
|
126
|
+
# @param [Array, Symbol] features
|
127
|
+
# @return [Hash]
|
128
|
+
|
129
|
+
# @!method exists?
|
130
|
+
# Shortcut for exists
|
131
|
+
# @return [Boolean]
|
132
|
+
|
133
|
+
# @!method alias_exists?
|
134
|
+
# Shortcut for alias_exists
|
135
|
+
# @return [Boolean]
|
136
|
+
|
137
|
+
# @!method setting_exists?
|
138
|
+
# Shortcut for setting_exists
|
139
|
+
# @return [Boolean]
|
140
|
+
|
141
|
+
# @!method mapping_exists?
|
142
|
+
# Shortcut for mapping_exists
|
143
|
+
# @return [Boolean]
|
144
|
+
|
145
|
+
# @!method meta_exists?
|
146
|
+
# Shortcut for meta_exists
|
147
|
+
# @return [Boolean]
|
148
|
+
|
71
149
|
# fast insert/update data.
|
72
150
|
#
|
73
151
|
# @example
|
@@ -44,11 +44,11 @@ module ElasticsearchRecord
|
|
44
44
|
end
|
45
45
|
|
46
46
|
# overwrite the limit_value setter, to provide a special behaviour of auto-setting the +max_result_window+.
|
47
|
-
def
|
47
|
+
def limit_value=(limit)
|
48
48
|
if limit == '__max__' || (limit.nil? && delegate_query_nil_limit?)
|
49
49
|
super(max_result_window)
|
50
50
|
else
|
51
|
-
super
|
51
|
+
super(limit)
|
52
52
|
end
|
53
53
|
end
|
54
54
|
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: elasticsearch_record
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.5.
|
4
|
+
version: 1.5.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Tobias Gonsior
|
8
|
-
autorequire:
|
8
|
+
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2023-07-
|
11
|
+
date: 2023-07-12 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: activerecord
|
@@ -94,10 +94,24 @@ dependencies:
|
|
94
94
|
- - "~>"
|
95
95
|
- !ruby/object:Gem::Version
|
96
96
|
version: 0.0.1
|
97
|
+
- !ruby/object:Gem::Dependency
|
98
|
+
name: yard-relative_markdown_links
|
99
|
+
requirement: !ruby/object:Gem::Requirement
|
100
|
+
requirements:
|
101
|
+
- - ">="
|
102
|
+
- !ruby/object:Gem::Version
|
103
|
+
version: '0.4'
|
104
|
+
type: :development
|
105
|
+
prerelease: false
|
106
|
+
version_requirements: !ruby/object:Gem::Requirement
|
107
|
+
requirements:
|
108
|
+
- - ">="
|
109
|
+
- !ruby/object:Gem::Version
|
110
|
+
version: '0.4'
|
97
111
|
description: 'ElasticsearchRecord is a ActiveRecord adapter and provides similar functionality
|
98
112
|
for Elasticsearch.
|
99
113
|
|
100
|
-
'
|
114
|
+
'
|
101
115
|
email:
|
102
116
|
- info@ruby-smart.org
|
103
117
|
executables: []
|
@@ -191,7 +205,7 @@ metadata:
|
|
191
205
|
source_code_uri: https://github.com/ruby-smart/elasticsearch_record
|
192
206
|
documentation_uri: https://rubydoc.info/gems/elasticsearch_record
|
193
207
|
changelog_uri: https://github.com/ruby-smart/elasticsearch_record/blob/main/docs/CHANGELOG.md
|
194
|
-
post_install_message:
|
208
|
+
post_install_message:
|
195
209
|
rdoc_options: []
|
196
210
|
require_paths:
|
197
211
|
- lib
|
@@ -206,8 +220,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
206
220
|
- !ruby/object:Gem::Version
|
207
221
|
version: '0'
|
208
222
|
requirements: []
|
209
|
-
rubygems_version: 3.
|
210
|
-
signing_key:
|
223
|
+
rubygems_version: 3.3.26
|
224
|
+
signing_key:
|
211
225
|
specification_version: 4
|
212
226
|
summary: ActiveRecord adapter for Elasticsearch
|
213
227
|
test_files: []
|