elasticsearch_record 1.2.3 → 1.2.4
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Gemfile.lock +2 -2
- data/docs/CHANGELOG.md +4 -0
- data/lib/arel/visitors/elasticsearch_query.rb +18 -0
- data/lib/elasticsearch_record/gem_version.rb +1 -1
- data/lib/elasticsearch_record/result.rb +28 -15
- 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: 41575ee0aefe81ed3069dc81c1c0d9062ea841998a7bb4affaab885dad0a4291
|
4
|
+
data.tar.gz: 73e98d4b6aad0fda63df0fff562537245f2d4c95fb5f53d67ad891550d8e6b1b
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: ed60e5fe591f92169d51f333c600338cd4fcee46ca6ca988625399ee522068e3b5c67738fe5b9f3fcc1cede6491cfb1b969c525d5b1af2f2ed03e93b7303237f
|
7
|
+
data.tar.gz: eb51b9dc16d0457905fb15589ff2542dfe0a8f59678459be910726305a3b0527e3ddcee6d7e5271e2db0d658dabd5f476eea71b4dca27c1f99375d987de50f0b
|
data/Gemfile.lock
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
PATH
|
2
2
|
remote: .
|
3
3
|
specs:
|
4
|
-
elasticsearch_record (1.2.
|
4
|
+
elasticsearch_record (1.2.4)
|
5
5
|
activerecord (~> 7.0.0)
|
6
6
|
elasticsearch (~> 8.4)
|
7
7
|
|
@@ -28,7 +28,7 @@ GEM
|
|
28
28
|
elasticsearch-api (= 8.5.2)
|
29
29
|
elasticsearch-api (8.5.2)
|
30
30
|
multi_json
|
31
|
-
faraday (2.7.
|
31
|
+
faraday (2.7.2)
|
32
32
|
faraday-net_http (>= 2.0, < 3.1)
|
33
33
|
ruby2_keywords (>= 0.0.4)
|
34
34
|
faraday-net_http (3.0.2)
|
data/docs/CHANGELOG.md
CHANGED
@@ -1,5 +1,9 @@
|
|
1
1
|
# ElasticsearchRecord - CHANGELOG
|
2
2
|
|
3
|
+
## [1.2.4] - 2022-12-15
|
4
|
+
* [fix] missing `#visit_Arel_Nodes_In` method in `Arel::Visitors::ElasticsearchQuery` to build array conditions
|
5
|
+
* [fix] resolving buckets from relation `ElasticsearchRecord::Result#buckets` not recognizing sub-buckets
|
6
|
+
|
3
7
|
## [1.2.3] - 2022-12-12
|
4
8
|
* [fix] `change_table` 'if_exists: true' returns at the wrong state
|
5
9
|
|
@@ -355,6 +355,23 @@ module Arel # :nodoc: all
|
|
355
355
|
end
|
356
356
|
end
|
357
357
|
|
358
|
+
# DIRECT ASSIGNMENT
|
359
|
+
def visit_Arel_Nodes_In(o)
|
360
|
+
self.collector.preparable = false
|
361
|
+
|
362
|
+
attr, values = o.left, o.right
|
363
|
+
|
364
|
+
if Array === values
|
365
|
+
unless values.empty?
|
366
|
+
values.delete_if { |value| unboundable?(value) }
|
367
|
+
end
|
368
|
+
|
369
|
+
return failed! if values.empty?
|
370
|
+
end
|
371
|
+
|
372
|
+
assign(:filter, [{ terms: { visit(attr) => visit(values) } }])
|
373
|
+
end
|
374
|
+
|
358
375
|
def visit_Arel_Nodes_And(o)
|
359
376
|
collect(o.children)
|
360
377
|
end
|
@@ -393,6 +410,7 @@ module Arel # :nodoc: all
|
|
393
410
|
claim(:index, o.name)
|
394
411
|
end
|
395
412
|
|
413
|
+
# RAW RETURN
|
396
414
|
def visit_Struct_Raw(o)
|
397
415
|
o
|
398
416
|
end
|
@@ -72,21 +72,7 @@ module ElasticsearchRecord
|
|
72
72
|
# aggregations are already a hash with key => data, but to prevent reference manipulation on the hash
|
73
73
|
# we have to create a new one here...
|
74
74
|
aggregations.reduce({}) { |buckets, (key, agg)|
|
75
|
-
|
76
|
-
if agg.key?(:buckets)
|
77
|
-
buckets[key] = agg[:buckets].reduce({}) { |m, b|
|
78
|
-
# buckets can be a Hash or Array (of Hashes)
|
79
|
-
bucket_key, bucket = b.is_a?(Hash) ? [b[:key], b] : b
|
80
|
-
m[bucket_key] = bucket.except(:key, :doc_count).transform_values { |val| val[:value] }
|
81
|
-
|
82
|
-
m
|
83
|
-
}
|
84
|
-
elsif agg.key?(:value)
|
85
|
-
buckets[key] = agg[:value]
|
86
|
-
elsif agg.key?(:values)
|
87
|
-
buckets[key] = agg[:values]
|
88
|
-
end
|
89
|
-
|
75
|
+
buckets[key] = _resolve_bucket(agg)
|
90
76
|
buckets
|
91
77
|
}.with_indifferent_access
|
92
78
|
end
|
@@ -247,6 +233,33 @@ module ElasticsearchRecord
|
|
247
233
|
end
|
248
234
|
end
|
249
235
|
|
236
|
+
# resolves bucket nodes recursively
|
237
|
+
# @param [Object] node
|
238
|
+
# @return [Object]
|
239
|
+
def _resolve_bucket(node)
|
240
|
+
# check, if node is not a hash - in this case we just return it's value
|
241
|
+
return node unless node.is_a?(Hash)
|
242
|
+
|
243
|
+
# check if the node has a bucket
|
244
|
+
if node.key?(:buckets)
|
245
|
+
node[:buckets].reduce({}) { |m, b|
|
246
|
+
# buckets can be a Hash or Array (of Hashes)
|
247
|
+
bucket_key, bucket = b.is_a?(Hash) ? [b[:key], b] : b
|
248
|
+
|
249
|
+
m[bucket_key] = _resolve_bucket(bucket)
|
250
|
+
m
|
251
|
+
}
|
252
|
+
elsif node.key?(:value)
|
253
|
+
node[:value]
|
254
|
+
elsif node.key?(:values)
|
255
|
+
node[:values]
|
256
|
+
else
|
257
|
+
# resolve sub-aggregations / nodes without 'meta' keys.
|
258
|
+
# if this results in an empty hash, the return will be nil
|
259
|
+
node.except(:key, :doc_count, :doc_count_error_upper_bound, :sum_other_doc_count).transform_values { |val| _resolve_bucket(val) }.presence
|
260
|
+
end
|
261
|
+
end
|
262
|
+
|
250
263
|
# builds computed results (used to build ActiveRecord models)
|
251
264
|
# @return [Array]
|
252
265
|
def computed_results
|
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.2.
|
4
|
+
version: 1.2.4
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Tobias Gonsior
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2022-12-
|
11
|
+
date: 2022-12-15 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: activerecord
|