elasticsearch_record 1.0.2 → 1.1.0
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/.yardopts +4 -0
- data/Gemfile.lock +10 -14
- data/README.md +180 -27
- data/docs/CHANGELOG.md +36 -18
- data/docs/LICENSE.txt +1 -1
- data/elasticsearch_record.gemspec +42 -0
- data/lib/active_record/connection_adapters/elasticsearch/column.rb +20 -6
- data/lib/active_record/connection_adapters/elasticsearch/database_statements.rb +142 -125
- data/lib/active_record/connection_adapters/elasticsearch/quoting.rb +2 -23
- data/lib/active_record/connection_adapters/elasticsearch/schema_creation.rb +30 -0
- data/lib/active_record/connection_adapters/elasticsearch/schema_definitions/attribute_methods.rb +103 -0
- data/lib/active_record/connection_adapters/elasticsearch/schema_definitions/column_methods.rb +42 -0
- data/lib/active_record/connection_adapters/elasticsearch/schema_definitions/create_table_definition.rb +158 -0
- data/lib/active_record/connection_adapters/elasticsearch/schema_definitions/table_alias_definition.rb +32 -0
- data/lib/active_record/connection_adapters/elasticsearch/schema_definitions/table_definition.rb +132 -0
- data/lib/active_record/connection_adapters/elasticsearch/schema_definitions/table_mapping_definition.rb +110 -0
- data/lib/active_record/connection_adapters/elasticsearch/schema_definitions/table_setting_definition.rb +136 -0
- data/lib/active_record/connection_adapters/elasticsearch/schema_definitions/update_table_definition.rb +174 -0
- data/lib/active_record/connection_adapters/elasticsearch/schema_definitions.rb +37 -0
- data/lib/active_record/connection_adapters/elasticsearch/schema_dumper.rb +110 -0
- data/lib/active_record/connection_adapters/elasticsearch/schema_statements.rb +398 -174
- data/lib/active_record/connection_adapters/elasticsearch/table_statements.rb +232 -0
- data/lib/active_record/connection_adapters/elasticsearch/type/multicast_value.rb +2 -0
- data/lib/active_record/connection_adapters/elasticsearch/unsupported_implementation.rb +32 -0
- data/lib/active_record/connection_adapters/elasticsearch_adapter.rb +112 -19
- data/lib/arel/collectors/elasticsearch_query.rb +0 -1
- data/lib/arel/visitors/elasticsearch.rb +7 -579
- data/lib/arel/visitors/elasticsearch_base.rb +234 -0
- data/lib/arel/visitors/elasticsearch_query.rb +463 -0
- data/lib/arel/visitors/elasticsearch_schema.rb +124 -0
- data/lib/elasticsearch_record/core.rb +44 -10
- data/lib/elasticsearch_record/errors.rb +13 -0
- data/lib/elasticsearch_record/gem_version.rb +6 -2
- data/lib/elasticsearch_record/instrumentation/log_subscriber.rb +27 -9
- data/lib/elasticsearch_record/model_schema.rb +5 -0
- data/lib/elasticsearch_record/persistence.rb +31 -26
- data/lib/elasticsearch_record/query.rb +56 -17
- data/lib/elasticsearch_record/querying.rb +17 -0
- data/lib/elasticsearch_record/relation/calculation_methods.rb +3 -0
- data/lib/elasticsearch_record/relation/core_methods.rb +57 -17
- data/lib/elasticsearch_record/relation/query_clause_tree.rb +38 -1
- data/lib/elasticsearch_record/relation/query_methods.rb +6 -0
- data/lib/elasticsearch_record/relation/result_methods.rb +15 -9
- data/lib/elasticsearch_record/result.rb +32 -5
- data/lib/elasticsearch_record/statement_cache.rb +2 -1
- data/lib/elasticsearch_record.rb +2 -2
- metadata +29 -11
- data/.ruby-version +0 -1
- data/lib/elasticsearch_record/schema_migration.rb +0 -30
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 6cf2af35e8ed5eb94892c5e1c6c5a7b11fab36539a48a3106b3444862c3654fc
|
4
|
+
data.tar.gz: 63f47637943c1e65e8d2a53c9f887b57ca5bdb139c4b6575997abbd640f2586d
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 96f3ce41b50dc97f5e4d9cdf79bf5b58af5bedcf219edee5d5d22a88b6517efcad0f3d7a0e26ca0042493d83a59d274a3f33d80ec4e16032c7ec50dfcb6790b2
|
7
|
+
data.tar.gz: c041e7d0bc2e00dd006d1c5b87e403b03f2e9c98a55672f636b29821a318425dc72aabff46e439a4c1281c914f1a07ac86487961f06930fac4169d538a2b9888
|
data/.yardopts
ADDED
data/Gemfile.lock
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
PATH
|
2
2
|
remote: .
|
3
3
|
specs:
|
4
|
-
elasticsearch_record (
|
4
|
+
elasticsearch_record (1.1.0)
|
5
5
|
activerecord (~> 7.0.0)
|
6
6
|
elasticsearch (~> 8.4)
|
7
7
|
|
@@ -20,19 +20,18 @@ GEM
|
|
20
20
|
tzinfo (~> 2.0)
|
21
21
|
concurrent-ruby (1.1.10)
|
22
22
|
diff-lcs (1.5.0)
|
23
|
-
docile (1.4.0)
|
24
23
|
elastic-transport (8.1.0)
|
25
24
|
faraday (< 3)
|
26
25
|
multi_json
|
27
|
-
elasticsearch (8.
|
26
|
+
elasticsearch (8.5.2)
|
28
27
|
elastic-transport (~> 8)
|
29
|
-
elasticsearch-api (= 8.
|
30
|
-
elasticsearch-api (8.
|
28
|
+
elasticsearch-api (= 8.5.2)
|
29
|
+
elasticsearch-api (8.5.2)
|
31
30
|
multi_json
|
32
|
-
faraday (2.
|
31
|
+
faraday (2.7.1)
|
33
32
|
faraday-net_http (>= 2.0, < 3.1)
|
34
33
|
ruby2_keywords (>= 0.0.4)
|
35
|
-
faraday-net_http (3.0.
|
34
|
+
faraday-net_http (3.0.2)
|
36
35
|
i18n (1.12.0)
|
37
36
|
concurrent-ruby (~> 1.0)
|
38
37
|
minitest (5.16.3)
|
@@ -52,14 +51,11 @@ GEM
|
|
52
51
|
rspec-support (~> 3.11.0)
|
53
52
|
rspec-support (3.11.1)
|
54
53
|
ruby2_keywords (0.0.5)
|
55
|
-
simplecov (0.21.2)
|
56
|
-
docile (~> 1.1)
|
57
|
-
simplecov-html (~> 0.11)
|
58
|
-
simplecov_json_formatter (~> 0.1)
|
59
|
-
simplecov-html (0.12.3)
|
60
|
-
simplecov_json_formatter (0.1.4)
|
61
54
|
tzinfo (2.0.5)
|
62
55
|
concurrent-ruby (~> 1.0)
|
56
|
+
webrick (1.7.0)
|
57
|
+
yard (0.9.28)
|
58
|
+
webrick (~> 1.7.0)
|
63
59
|
|
64
60
|
PLATFORMS
|
65
61
|
x86_64-linux
|
@@ -68,7 +64,7 @@ DEPENDENCIES
|
|
68
64
|
elasticsearch_record!
|
69
65
|
rake (~> 13.0)
|
70
66
|
rspec (~> 3.0)
|
71
|
-
|
67
|
+
yard (~> 0.9)
|
72
68
|
|
73
69
|
BUNDLED WITH
|
74
70
|
2.3.18
|
data/README.md
CHANGED
@@ -1,6 +1,10 @@
|
|
1
1
|
# ElasticsearchRecord
|
2
2
|
|
3
|
+
[](http://github.com/ruby-smart/elasticsearch_record)
|
4
|
+
[](http://rubydoc.info/gems/elasticsearch_record)
|
5
|
+
|
3
6
|
[](https://badge.fury.io/rb/elasticsearch_record)
|
7
|
+
[](docs/LICENSE.txt)
|
4
8
|
|
5
9
|
ActiveRecord adapter for Elasticsearch
|
6
10
|
|
@@ -9,6 +13,7 @@ _ElasticsearchRecord is a ActiveRecord adapter and provides similar functionalit
|
|
9
13
|
-----
|
10
14
|
|
11
15
|
**PLEASE NOTE:**
|
16
|
+
|
12
17
|
- This is still in **development**!
|
13
18
|
- Specs & documentation will follow.
|
14
19
|
- You might experience BUGs and Exceptions...
|
@@ -34,19 +39,25 @@ Or install it yourself as:
|
|
34
39
|
|
35
40
|
|
36
41
|
## Features
|
37
|
-
*
|
38
|
-
*
|
39
|
-
*
|
40
|
-
*
|
42
|
+
* ActiveRecord's `create, read, update & delete` behaviours
|
43
|
+
* Active Record Query Interface
|
44
|
+
* query-chaining
|
45
|
+
* scopes
|
46
|
+
* additional relation methods to find records with `filter, must, must_not, should`
|
47
|
+
* aggregated queries with Elasticsearch `aggregation` methods
|
48
|
+
* resolve search response `hits`, `aggregations`, `buckets`, ... instead of ActiveRecord objects
|
49
|
+
* Third-party gem support
|
50
|
+
* access `elasticsearch-dsl` query builder through `model.search{ ... }`
|
51
|
+
* Schema
|
52
|
+
* dump
|
53
|
+
* create & update of tables _(indices)_ with mappings, settings & aliases
|
41
54
|
* Instrumentation for ElasticsearchRecord
|
55
|
+
* logs Elasticsearch API-calls
|
56
|
+
* shows Runtime in logs
|
42
57
|
|
43
58
|
## Contra - what it _(currently)_ can not
|
44
|
-
*
|
59
|
+
* Joins to other indexes or databases
|
45
60
|
* complex, combined or nested queries ```and, or, Model.arel ...```
|
46
|
-
* Create mappings / schema through migrations _(so no create_table, update_column, ...)_
|
47
|
-
* Schema dumps
|
48
|
-
* Manage indexes and mappings
|
49
|
-
|
50
61
|
|
51
62
|
## Setup
|
52
63
|
|
@@ -103,11 +114,19 @@ end
|
|
103
114
|
|
104
115
|
### d) have FUN with your model:
|
105
116
|
```ruby
|
106
|
-
scope = Search
|
117
|
+
scope = Search
|
118
|
+
.where(name: 'Custom Object Name')
|
119
|
+
.where(token: nil)
|
120
|
+
.filter(terms: {type: [:x, :y]})
|
121
|
+
.limit(5)
|
122
|
+
|
123
|
+
# take the first object
|
107
124
|
obj = scope.take
|
108
125
|
|
126
|
+
# update the objects name
|
109
127
|
obj.update(name: "Not-So-Important")
|
110
128
|
|
129
|
+
# extend scope and update all docs
|
111
130
|
scope.where(kind: :undefined).offset(10).update_all(name: "New Name")
|
112
131
|
|
113
132
|
```
|
@@ -115,7 +134,6 @@ scope.where(kind: :undefined).offset(10).update_all(name: "New Name")
|
|
115
134
|
## Active Record Query Interface
|
116
135
|
|
117
136
|
### Refactored ```where``` method:
|
118
|
-
|
119
137
|
Different to the default where-method you can now use it in different ways.
|
120
138
|
|
121
139
|
Using it by default with a Hash, the method decides itself to either add a filter, or must_not query.
|
@@ -141,17 +159,42 @@ Search.where(:should, term: {name: 'Mano'})
|
|
141
159
|
# > should: {term: {name: 'Mano'}}
|
142
160
|
```
|
143
161
|
|
144
|
-
###
|
162
|
+
### Result methods:
|
163
|
+
You can simply return RAW data without instantiating ActiveRecord objects:
|
164
|
+
|
145
165
|
```ruby
|
146
|
-
# save a new record
|
147
|
-
model = Search.new(name: "Cool object", kind: "open")
|
148
|
-
model.save
|
149
166
|
|
150
|
-
#
|
151
|
-
|
167
|
+
# returns the response RAW hits hash.
|
168
|
+
hits = Search.where(name: 'A nice object').hits
|
169
|
+
# > {"total"=>{"value"=>5, "relation"=>"eq"}, "max_score"=>1.0, "hits"=>[{ "_index": "search", "_type": "_doc", "_id": "abc123", "_score": 1.0, "_source": { "name": "A nice object", ...
|
170
|
+
|
171
|
+
# Returns the RAW +_source+ data from each hit - aka. +rows+.
|
172
|
+
results = Search.where(name: 'A nice object').results
|
173
|
+
# > [{ "name": "A nice object", ...
|
174
|
+
|
175
|
+
# returns the response RAW aggregations hash.
|
176
|
+
aggs = Search.where(name: 'A nice object').aggregate(:total, {sum: {field: :amount}}).aggregations
|
177
|
+
# > {"total"=>{"value"=>6722604.0}}
|
178
|
+
|
179
|
+
# returns the (nested) bucket values (and aggregated values) from the response aggregations.
|
180
|
+
buckets = Search.where(name: 'A nice object').aggregate(:total, {sum: {field: :amount}}).buckets
|
181
|
+
# > {"total"=>6722604.0}
|
182
|
+
|
183
|
+
# resolves RAW +_source+ data from each hit with a +point_in_time+ query (also includes _id)
|
184
|
+
# useful if you want more then 10000 results.
|
185
|
+
results = Search.where(name: 'A nice object').pit_results
|
186
|
+
# > [{ "_id": "abc123", "name": "A nice object", ...
|
187
|
+
|
188
|
+
# returns the total value of the query without querying again (it uses the total value from the response)
|
189
|
+
scope = Search.where(name: 'A nice object').limit(5)
|
190
|
+
results_count = scope.count
|
191
|
+
# > 5
|
192
|
+
total = scope.total
|
193
|
+
# > 3335
|
194
|
+
|
152
195
|
```
|
153
196
|
|
154
|
-
###
|
197
|
+
### Available query/relation chain methods
|
155
198
|
- kind
|
156
199
|
- configure
|
157
200
|
- aggregate
|
@@ -161,8 +204,12 @@ MyEsIndex.find_by_id("xyzAbc34")
|
|
161
204
|
- must
|
162
205
|
- should
|
163
206
|
- aggregate
|
207
|
+
- restrict
|
208
|
+
- hits_only!
|
209
|
+
- aggs_only!
|
210
|
+
- total_only!
|
164
211
|
|
165
|
-
###
|
212
|
+
### Available calculation methods
|
166
213
|
- percentiles
|
167
214
|
- percentile_ranks
|
168
215
|
- cardinality
|
@@ -172,8 +219,9 @@ MyEsIndex.find_by_id("xyzAbc34")
|
|
172
219
|
- sum
|
173
220
|
- calculate
|
174
221
|
|
175
|
-
###
|
222
|
+
### Available result methods
|
176
223
|
- aggregations
|
224
|
+
- buckets
|
177
225
|
- hits
|
178
226
|
- results
|
179
227
|
- total
|
@@ -188,31 +236,136 @@ MyEsIndex.find_by_id("xyzAbc34")
|
|
188
236
|
|
189
237
|
-----
|
190
238
|
|
191
|
-
### Useful model
|
239
|
+
### Useful model class attributes
|
192
240
|
- index_base_name
|
241
|
+
- relay_id_attribute
|
193
242
|
|
194
|
-
### Useful model methods
|
243
|
+
### Useful model instance methods
|
195
244
|
- source_column_names
|
196
245
|
- searchable_column_names
|
197
246
|
- find_by_query
|
198
247
|
- msearch
|
199
248
|
|
249
|
+
## ActiveRecord ConnectionAdapters schema-methods
|
250
|
+
Access these methods through the model's connection.
|
251
|
+
```ruby
|
252
|
+
# returns mapping of provided table (index)
|
253
|
+
model.connection.table_mappings('table-name')
|
254
|
+
```
|
255
|
+
|
256
|
+
- table_mappings
|
257
|
+
- table_settings
|
258
|
+
- table_aliases
|
259
|
+
- table_state
|
260
|
+
- table_schema
|
261
|
+
- alias_exists?
|
262
|
+
- setting_exists?
|
263
|
+
- mapping_exists?
|
264
|
+
- max_result_window
|
265
|
+
- cluster_info
|
266
|
+
|
267
|
+
## Active Record Schema migration methods
|
268
|
+
Access these methods through the model's connection or within any `Migration`.
|
269
|
+
|
270
|
+
- open_table
|
271
|
+
- open_tables
|
272
|
+
- close_table
|
273
|
+
- close_tables
|
274
|
+
- truncate_table
|
275
|
+
- truncate_tables
|
276
|
+
- drop_table
|
277
|
+
- create_table
|
278
|
+
- change_table
|
279
|
+
- add_mapping
|
280
|
+
- change_mapping
|
281
|
+
- change_mapping_meta
|
282
|
+
- change_mapping_attributes
|
283
|
+
- add_setting
|
284
|
+
- change_setting
|
285
|
+
- delete_setting
|
286
|
+
- add_alias
|
287
|
+
- change_alias
|
288
|
+
- delete_alias
|
289
|
+
|
290
|
+
```ruby
|
291
|
+
# Example migration
|
292
|
+
class AddTests < ActiveRecord::Migration[7.0]
|
293
|
+
def up
|
294
|
+
create_table "assignments", if_not_exists: true do |t|
|
295
|
+
t.string :key, primary_key: true
|
296
|
+
t.text :value
|
297
|
+
t.timestamps
|
298
|
+
|
299
|
+
t.setting :number_of_shards, "1"
|
300
|
+
t.setting :number_of_replicas, 0
|
301
|
+
end
|
302
|
+
|
303
|
+
create_table "settings", force: true do |t|
|
304
|
+
t.mapping :created_at, :date
|
305
|
+
t.mapping :key, :keyword do |m|
|
306
|
+
m.primary_key = true
|
307
|
+
end
|
308
|
+
t.mapping :status, :keyword
|
309
|
+
t.mapping :updated_at, :date
|
310
|
+
t.mapping :value, :text
|
311
|
+
|
312
|
+
t.setting "index.number_of_replicas", "0"
|
313
|
+
t.setting "index.number_of_shards", "1"
|
314
|
+
t.setting "index.routing.allocation.include._tier_preference", "data_content"
|
315
|
+
end
|
316
|
+
|
317
|
+
add_mapping "settings", :active, :boolean do |m|
|
318
|
+
m.comment = "Hans"
|
319
|
+
end
|
320
|
+
|
321
|
+
change_table 'settings', force: true do |t|
|
322
|
+
t.add_setting( "index.search.idle.after", "20s")
|
323
|
+
t.add_setting("index.shard.check_on_startup", true)
|
324
|
+
t.add_alias('supersettings')
|
325
|
+
end
|
326
|
+
|
327
|
+
delete_alias('settings', :supersettings)
|
328
|
+
delete_setting('settings', 'index.search.idle.after')
|
329
|
+
|
330
|
+
change_table 'settings', force: true do |t|
|
331
|
+
t.integer :amount_of_newbies
|
332
|
+
end
|
333
|
+
|
334
|
+
create_table "vintage", force: true do |t|
|
335
|
+
t.primary_key :number
|
336
|
+
t.string :name
|
337
|
+
t.timestamps
|
338
|
+
end
|
339
|
+
|
340
|
+
change_mapping_meta "vintage", :number, auto_increment: 'true'
|
341
|
+
change_mapping_meta "vintage", :number, peter: 'hans'
|
342
|
+
|
343
|
+
change_mapping_attributes "vintage", :number, fields: {raw: {type: :keyword}}
|
344
|
+
end
|
345
|
+
|
346
|
+
def down
|
347
|
+
drop_table 'assignments'
|
348
|
+
drop_table 'settings'
|
349
|
+
drop_table 'vintage'
|
350
|
+
end
|
351
|
+
end
|
352
|
+
```
|
200
353
|
|
201
354
|
## Docs
|
202
355
|
|
203
|
-
[CHANGELOG](
|
356
|
+
[CHANGELOG](docs/CHANGELOG.md)
|
204
357
|
|
205
358
|
## Contributing
|
206
359
|
|
207
|
-
Bug reports and pull requests are welcome on GitHub
|
208
|
-
This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the [code of conduct](
|
360
|
+
Bug reports and pull requests are welcome on [GitHub](https://github.com/ruby-smart/elasticsearch_record).
|
361
|
+
This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the [code of conduct](docs/CODE_OF_CONDUCT.md).
|
209
362
|
|
210
363
|
## License
|
211
364
|
|
212
365
|
The gem is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT).
|
213
366
|
|
214
|
-
A copy of the [LICENSE](
|
367
|
+
A copy of the [LICENSE](docs/LICENSE.txt) can be found @ the docs.
|
215
368
|
|
216
369
|
## Code of Conduct
|
217
370
|
|
218
|
-
Everyone interacting in the project's codebases, issue trackers, chat rooms and mailing lists is expected to follow the [CODE OF CONDUCT](
|
371
|
+
Everyone interacting in the project's codebases, issue trackers, chat rooms and mailing lists is expected to follow the [CODE OF CONDUCT](docs/CODE_OF_CONDUCT.md).
|
data/docs/CHANGELOG.md
CHANGED
@@ -1,43 +1,61 @@
|
|
1
1
|
# ElasticsearchRecord - CHANGELOG
|
2
2
|
|
3
|
+
## [1.1.0] - 2022-12-02
|
4
|
+
* [add] support for schema dumps & migrations for Elasticsearch
|
5
|
+
* [add] `buckets` query/relation result method to resolve the buckets as key->value hash from aggregations
|
6
|
+
* [add] support for third-party gems (e.g. elasticsearch-dsl)
|
7
|
+
* [add] custom primary_key support with 'auto_increment' adaption _(beta)_
|
8
|
+
* [ref] instrumentation of `LogSubscriber` coloring
|
9
|
+
* [ref] unsupported methods to show exception
|
10
|
+
* [ref] query/relation method `#msearch` to support options 'resolve', 'transpose' & 'keep_null_relation'
|
11
|
+
* [ref] `ActiveRecord::ConnectionAdapters::ElasticsearchAdapter#translate_exception` for better error handling
|
12
|
+
* [ref] `ActiveRecord::ConnectionAdapters::Elasticsearch::Column` for a much easier assignment
|
13
|
+
* [ref] gemspec, yardoc & docs
|
14
|
+
* [fix] `ActiveRecord::ConnectionAdapters::ElasticsearchAdapter::BASE_STRUCTURE` to force primary_key column '_id' as virtual
|
15
|
+
* [fix] `ElasticsearchRecord::Relation::QueryClauseTree` not correctly calculating & merging 'filters, musts, ... '
|
16
|
+
* [fix] failing query not really failing in nested queries (msearch)
|
17
|
+
* [fix] 'null_realation' being executed in msearch
|
18
|
+
* [fix] quoting of columns, attributes & values
|
19
|
+
* [fix] query/relation method `#count` not preventing 'null_relation?'
|
20
|
+
|
3
21
|
## [1.0.2] - 2022-11-07
|
4
|
-
* [add]
|
22
|
+
* [add] `ActiveRecord::ConnectionAdapters::ElasticsearchAdapter#migrations_paths` with 'db/migrate_elasticsearch'
|
5
23
|
* [fix] to prevent executing 'primary' migrations to elasticsearch (SchemaDumper may still throw error comments)
|
6
24
|
* [add] temporary workarounds for scheme & migrations until we support it (so bin/rails db:migrate - tasks will now run again)
|
7
25
|
|
8
26
|
## [1.0.1] - 2022-10-19
|
9
|
-
* [add]
|
27
|
+
* [add] `ActiveRecord::ConnectionAdapters::Elasticsearch::Type::Nested` class to cast nested values
|
10
28
|
* [add] **properties** to column definition (so they are also searchable by _Relation_ conditions)
|
11
29
|
* [add] exception for _Relation_ #pit_results if batch size is too large
|
12
30
|
* [add] a default _#find_by_id_-method to proved a 'fallback' functionality for the primary '_id' column
|
13
31
|
* [fix] nested properties are not cast for column-type "object"
|
14
|
-
* [fix]
|
15
|
-
* [fix]
|
16
|
-
* [ref]
|
17
|
-
* [ref]
|
32
|
+
* [fix] `ActiveRecord::ConnectionAdapters::Elasticsearch::SchemaStatements` fields and property detection
|
33
|
+
* [fix] `ElasticsearchRecord::StatementCache::PartialQuery` reference manipulation of cached hash _(missing .deep_dup )_
|
34
|
+
* [ref] `ActiveRecord::ConnectionAdapters::Elasticsearch::Type::Object` class to only cast object values
|
35
|
+
* [ref] `Arel::Visitors::Elasticsearch#visit_Sort` to detect a random sort with correct keyword: "**\_\_rand\_\_**"
|
18
36
|
|
19
37
|
## [1.0.0] - 2022-10-18
|
20
|
-
* [add] patch for
|
21
|
-
* [add]
|
22
|
-
* [add] individual instrumentation names for
|
38
|
+
* [add] patch for `ActiveRecord::Relation::Merger` - to support AR-relations
|
39
|
+
* [add] `ElasticsearchRecord::Relation#pit_results` _offset_ & _yield_ support
|
40
|
+
* [add] individual instrumentation names for `ElasticsearchRecord::Relation` result methods (like: #aggregations)
|
23
41
|
* [rem] cleanup Debugging & logging
|
24
42
|
* [fix] quoting for any values
|
25
|
-
* [fix] calculation
|
26
|
-
* [fix]
|
43
|
+
* [fix] calculation `count` method to support already known syntax (with column, distinct, limited, ...)
|
44
|
+
* [fix] `Arel::Nodes` to support additional args (query, kind, aggs, ...)
|
27
45
|
* [fix] _relation manager patch_ to not mash up different relations
|
28
|
-
* [fix]
|
29
|
-
* [fix]
|
30
|
-
* [fix]
|
46
|
+
* [fix] `ElasticsearchRecord` total calculation for failed queries
|
47
|
+
* [fix] `ElasticsearchRecord::Relation#count` to correctly _unscope_
|
48
|
+
* [fix] `Arel::Visitors::Elasticsearch`
|
31
49
|
* build query where-clauses without existing default query-"kind"
|
32
50
|
* directly fail if a grouping _(visit_Arel_Nodes_Grouping)_ was provided
|
33
51
|
* forced _failed!_ state was not correctly claimed
|
34
52
|
* buggy _assign_-method for nested arrays
|
35
|
-
* [fix]
|
53
|
+
* [fix] `Arel::Collectors::ElasticsearchQuery`
|
36
54
|
* claim for _argument_
|
37
55
|
* delete key on _nil_ assign
|
38
|
-
* [ref] simplify
|
39
|
-
* [ref] simplify
|
40
|
-
* [ref] rename
|
56
|
+
* [ref] simplify `Arel::Collectors::ElasticsearchQuery` (remove stack & scoping)
|
57
|
+
* [ref] simplify `Arel::Visitors::Elasticsearch` to support binds (statement cache) and simple where predicates
|
58
|
+
* [ref] rename `ElasticsearchRecord::Query#arguments` -> _#query_arguments_
|
41
59
|
|
42
60
|
## [0.1.2] - 2022-09-23
|
43
61
|
* [fix] Records / Elasticsearch index with additional 'id' fields not recognizing
|
data/docs/LICENSE.txt
CHANGED
@@ -0,0 +1,42 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require_relative "lib/elasticsearch_record/version"
|
4
|
+
|
5
|
+
Gem::Specification.new do |spec|
|
6
|
+
spec.name = "elasticsearch_record"
|
7
|
+
spec.version = ElasticsearchRecord.version
|
8
|
+
spec.authors = ["Tobias Gonsior"]
|
9
|
+
spec.email = ["info@ruby-smart.org"]
|
10
|
+
spec.summary = "ActiveRecord adapter for Elasticsearch"
|
11
|
+
spec.description = <<DESC
|
12
|
+
ElasticsearchRecord is a ActiveRecord adapter and provides similar functionality for Elasticsearch.
|
13
|
+
DESC
|
14
|
+
|
15
|
+
spec.homepage = "https://github.com/ruby-smart/elasticsearch_record"
|
16
|
+
spec.license = "MIT"
|
17
|
+
spec.required_ruby_version = ">= 2.7.0"
|
18
|
+
|
19
|
+
spec.metadata["allowed_push_host"] = "https://rubygems.org"
|
20
|
+
spec.metadata["homepage_uri"] = spec.homepage
|
21
|
+
spec.metadata["source_code_uri"] = "https://github.com/ruby-smart/elasticsearch_record"
|
22
|
+
spec.metadata['documentation_uri'] = 'https://rubydoc.info/gems/elasticsearch_record'
|
23
|
+
spec.metadata["changelog_uri"] = "#{spec.metadata["source_code_uri"]}/blob/main/docs/CHANGELOG.md"
|
24
|
+
|
25
|
+
# Specify which files should be added to the gem when it is released.
|
26
|
+
# The `git ls-files -z` loads the files in the RubyGem that have been added into git.
|
27
|
+
spec.files = Dir.chdir(__dir__) do
|
28
|
+
`git ls-files -z`.split("\x0").reject do |f|
|
29
|
+
(f == __FILE__) || f.match(%r{\A(?:(?:bin|test|spec|features)/|\.(?:git|travis|circleci)|appveyor)})
|
30
|
+
end
|
31
|
+
end
|
32
|
+
|
33
|
+
spec.require_paths = ["lib"]
|
34
|
+
|
35
|
+
spec.add_dependency 'activerecord', '~> 7.0.0'
|
36
|
+
spec.add_dependency 'elasticsearch', '~> 8.4'
|
37
|
+
|
38
|
+
#spec.add_development_dependency 'coveralls_reborn', '~> 0.25'
|
39
|
+
spec.add_development_dependency 'rspec', '~> 3.0'
|
40
|
+
spec.add_development_dependency 'rake', "~> 13.0"
|
41
|
+
spec.add_development_dependency 'yard', '~> 0.9'
|
42
|
+
end
|
@@ -5,13 +5,20 @@ module ActiveRecord
|
|
5
5
|
module Elasticsearch
|
6
6
|
class Column < ConnectionAdapters::Column # :nodoc:
|
7
7
|
|
8
|
-
attr_reader :virtual, :fields, :properties
|
8
|
+
attr_reader :virtual, :fields, :properties, :meta
|
9
9
|
|
10
|
-
def initialize(name, default, sql_type_metadata = nil,
|
11
|
-
@virtual =
|
12
|
-
@fields =
|
13
|
-
@properties =
|
14
|
-
|
10
|
+
def initialize(name, default, sql_type_metadata = nil, virtual: false, fields: nil, properties: nil, meta: nil, **kwargs)
|
11
|
+
@virtual = virtual
|
12
|
+
@fields = fields.presence || []
|
13
|
+
@properties = properties.presence || []
|
14
|
+
@meta = meta.presence || {}
|
15
|
+
|
16
|
+
super(name, default, sql_type_metadata, true, nil, **kwargs)
|
17
|
+
end
|
18
|
+
|
19
|
+
# returns comment from meta
|
20
|
+
def comment
|
21
|
+
meta? && meta['comment']
|
15
22
|
end
|
16
23
|
|
17
24
|
# returns true if this column is virtual.
|
@@ -21,6 +28,13 @@ module ActiveRecord
|
|
21
28
|
!!virtual
|
22
29
|
end
|
23
30
|
|
31
|
+
# returns true if this column has meta information
|
32
|
+
# To receive the nested meta-data just call +#meta+ on this object.
|
33
|
+
# @return [Boolean]
|
34
|
+
def meta?
|
35
|
+
meta.present?
|
36
|
+
end
|
37
|
+
|
24
38
|
# returns true if this column has nested fields
|
25
39
|
# To receive the nested names just call +#fields+ on this object.
|
26
40
|
# @return [Boolean]
|