realm-elasticsearch 0.7.4 → 0.7.5
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/realm/elasticsearch/repository.rb +14 -13
- 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: 4df872d46e83ab9b88eb158d3304bcd802d9df8bf75c5d4bda2343c89413e658
|
4
|
+
data.tar.gz: f2228d93e40b1e2d873f771c59d57f799eed9ea88474d6c54903999512cb733a
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: '09454900567b01be181a1d4a00173d9b1995823d504dc70377f3e9575b98bec2d2a494d7e068d14cbd72678e0dde57b953746e30e9fa9b934e2ce16167a7eeea'
|
7
|
+
data.tar.gz: 4cfc783255ada052bc36514ea840079923ee5930b2171397bb0763e94d19a7e434db428ac58d0c9d2a3719358d10865330021c542146134fe317f198bb961a6b
|
@@ -22,13 +22,13 @@ module Realm
|
|
22
22
|
end
|
23
23
|
|
24
24
|
def find(id:)
|
25
|
-
|
25
|
+
format_single(client.get(index: index_name, id: id))
|
26
26
|
rescue ::Elasticsearch::Transport::Transport::Errors::NotFound
|
27
27
|
nil
|
28
28
|
end
|
29
29
|
|
30
30
|
def all
|
31
|
-
|
31
|
+
format_multiple(raw_search(query: { match_all: {} }))
|
32
32
|
end
|
33
33
|
|
34
34
|
def create(id: nil, **attrs)
|
@@ -53,7 +53,7 @@ module Realm
|
|
53
53
|
end
|
54
54
|
|
55
55
|
def search_by(params)
|
56
|
-
|
56
|
+
format_multiple(raw_search(query: { bool: { must: match_params(params) } }))
|
57
57
|
end
|
58
58
|
|
59
59
|
def delete_by(params)
|
@@ -85,6 +85,17 @@ module Realm
|
|
85
85
|
)
|
86
86
|
end
|
87
87
|
|
88
|
+
protected
|
89
|
+
|
90
|
+
def format_single(result)
|
91
|
+
result['_source'].merge(id: result['_id']).deep_symbolize_keys
|
92
|
+
end
|
93
|
+
|
94
|
+
def format_multiple(results)
|
95
|
+
docs = results.dig('hits', 'hits').map { |doc| format_single(doc) }
|
96
|
+
{ docs: docs }
|
97
|
+
end
|
98
|
+
|
88
99
|
private
|
89
100
|
|
90
101
|
attr_reader :client
|
@@ -95,16 +106,6 @@ module Realm
|
|
95
106
|
defined?(::Rails) && ::Rails.env.test?
|
96
107
|
end
|
97
108
|
|
98
|
-
def single(result)
|
99
|
-
id = result['_id'].then { |i| i.to_i.positive? ? i.to_i : i }
|
100
|
-
result['_source'].merge(id: id).deep_symbolize_keys
|
101
|
-
end
|
102
|
-
|
103
|
-
def multiple(results)
|
104
|
-
docs = results.dig('hits', 'hits').map { |doc| single(doc) }
|
105
|
-
{ docs: docs }
|
106
|
-
end
|
107
|
-
|
108
109
|
def match_params(params)
|
109
110
|
params.map { |(key, value)| { match: { key => value } } }
|
110
111
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: realm-elasticsearch
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.7.
|
4
|
+
version: 0.7.5
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- developers@reevoo.com
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2021-07-
|
11
|
+
date: 2021-07-15 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: elasticsearch
|