sequel-elasticsearch 0.3.2 → 0.3.3
Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 9fedd83674e13bf3111df6c01a4a7c997e39cfd16906ea9849c5e22ca9944d36
|
4
|
+
data.tar.gz: 3799f9f9eba3821790e96abf8d00016600dc71cb6620c439c6dd82ffb69dd09e
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 7219a5449f7c7a88f49a71d43ed1cce202e6312ad050cdde494171289aed5ee199628ba7d2cc36b3c28344aff5fdb76a94acea6701cb224cb15062a474aa3994
|
7
|
+
data.tar.gz: 2db11be8b0cb25339a3399325511a992c69591147b9810978aa03cf2c223f97dc10f7217dbb75720ea6ae82bac2a03ec38c8c5b0451e682959b3eacd448253e3
|
@@ -4,23 +4,40 @@ module Sequel
|
|
4
4
|
class Result
|
5
5
|
include Enumerable
|
6
6
|
|
7
|
-
attr_reader :results, :scroll_id, :total, :took, :timed_out
|
7
|
+
attr_reader :results, :scroll_id, :total, :took, :timed_out, :model
|
8
8
|
|
9
|
-
def initialize(results)
|
9
|
+
def initialize(results, model = nil)
|
10
10
|
return unless results && results['hits']
|
11
11
|
@results = results
|
12
12
|
@scroll_id = results['_scroll_id']
|
13
13
|
@total = results['hits']['total']
|
14
14
|
@timed_out = results['timed_out']
|
15
15
|
@took = results['took']
|
16
|
+
@model = model
|
16
17
|
end
|
17
18
|
|
18
19
|
def each
|
19
20
|
return [] unless results['hits'] && results['hits']['hits']
|
20
|
-
results['hits']['hits'].each
|
21
|
+
results['hits']['hits'].each do |h|
|
22
|
+
yield convert(h)
|
23
|
+
end
|
21
24
|
# TODO: Use the scroll id to get more if needed
|
22
25
|
# We will need access to the client, somehow...
|
23
26
|
end
|
27
|
+
|
28
|
+
def all
|
29
|
+
results['hits']['hits'].map do |h|
|
30
|
+
convert(h)
|
31
|
+
end
|
32
|
+
end
|
33
|
+
|
34
|
+
private
|
35
|
+
|
36
|
+
def convert(hit)
|
37
|
+
return hit unless model
|
38
|
+
source = hit['_source'].each_with_object({}) { |(k, v), h| h[k.to_sym] = v }
|
39
|
+
model.call source
|
40
|
+
end
|
24
41
|
end
|
25
42
|
end
|
26
43
|
end
|
@@ -21,8 +21,8 @@ Gem::Specification.new do |spec|
|
|
21
21
|
spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
|
22
22
|
spec.require_paths = ['lib']
|
23
23
|
|
24
|
-
spec.add_dependency 'elasticsearch', '
|
25
|
-
spec.add_dependency 'sequel', '
|
24
|
+
spec.add_dependency 'elasticsearch', '>= 1.0'
|
25
|
+
spec.add_dependency 'sequel', '>= 4.0'
|
26
26
|
|
27
27
|
spec.add_development_dependency 'bundler', '~> 1.13'
|
28
28
|
spec.add_development_dependency 'rake', '~> 10.0'
|
metadata
CHANGED
@@ -1,43 +1,43 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: sequel-elasticsearch
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.3.
|
4
|
+
version: 0.3.3
|
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: 2018-02-
|
11
|
+
date: 2018-02-08 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: elasticsearch
|
15
15
|
requirement: !ruby/object:Gem::Requirement
|
16
16
|
requirements:
|
17
|
-
- - "
|
17
|
+
- - ">="
|
18
18
|
- !ruby/object:Gem::Version
|
19
|
-
version: '
|
19
|
+
version: '1.0'
|
20
20
|
type: :runtime
|
21
21
|
prerelease: false
|
22
22
|
version_requirements: !ruby/object:Gem::Requirement
|
23
23
|
requirements:
|
24
|
-
- - "
|
24
|
+
- - ">="
|
25
25
|
- !ruby/object:Gem::Version
|
26
|
-
version: '
|
26
|
+
version: '1.0'
|
27
27
|
- !ruby/object:Gem::Dependency
|
28
28
|
name: sequel
|
29
29
|
requirement: !ruby/object:Gem::Requirement
|
30
30
|
requirements:
|
31
|
-
- - "
|
31
|
+
- - ">="
|
32
32
|
- !ruby/object:Gem::Version
|
33
|
-
version: '
|
33
|
+
version: '4.0'
|
34
34
|
type: :runtime
|
35
35
|
prerelease: false
|
36
36
|
version_requirements: !ruby/object:Gem::Requirement
|
37
37
|
requirements:
|
38
|
-
- - "
|
38
|
+
- - ">="
|
39
39
|
- !ruby/object:Gem::Version
|
40
|
-
version: '
|
40
|
+
version: '4.0'
|
41
41
|
- !ruby/object:Gem::Dependency
|
42
42
|
name: bundler
|
43
43
|
requirement: !ruby/object:Gem::Requirement
|