esse 0.1.2 → 0.1.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: 4dff3560f305debeee691263267e43df0e70a17591f6ecfc897025a5c07ada8a
4
- data.tar.gz: a8ba452b0bfc81210f104293f852ecacaef585ea23b2e8f24177197fa2555e69
3
+ metadata.gz: '0785bd8298d822b9778cbbbd98e8ae6b97063d0c18e11da57266e6cb8129c08a'
4
+ data.tar.gz: ea927277c5d497bf37127f4c0467253d6163cbc2e011cee9af2095a38162e339
5
5
  SHA512:
6
- metadata.gz: 73bfc1a130c18df947cd02120087eed2b571fa174b84009b687dc0e343697aec1a1a20ae00eb0fc8465a9ad603d95318c02d324b98fe811baddc0b08d3533e28
7
- data.tar.gz: 160aaf9fdef9da05108c1e966cfc03a45f9357aeb4682d551458546f66dc067d0585e52f0836aa0b4ee8fb5d634d3b705bced6340e91a99013d571fcded5f574
6
+ metadata.gz: 11082f005792f640e9e731ae7b0709370b86c6d151773b8c514f9af87f764b0ba53dee2cf036c6f71168488993403d54b24e921ec75031a91c75f6580de239e8
7
+ data.tar.gz: 6f5d2ca3c8b9c2d2125560fcf9d1406210779743b28f0e58708e84dcd31ccad063d31b40f9ae9e5d4f1a6fdc8445e3897226db479fb5dfa96717adab09e2d0a9
@@ -0,0 +1,43 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Esse
4
+ # @abstract
5
+ #
6
+ # A document is a class that represents a single JSON document to be indexed
7
+ class Document
8
+ def initialize(entry, **context)
9
+ @source = item
10
+ @context = context
11
+ end
12
+
13
+ # Returns the Elasticsearch `_id` for the document.
14
+ #
15
+ # @return [String, Number] The Elasticsearch `_id` for the document
16
+ # @abstract
17
+ def id
18
+ raise NotImplementedError
19
+ end
20
+
21
+ # Returns the Elasticsearch `_routing` for the item. Elasticsearch
22
+ # default if this value is not provided is to use the `_id`.
23
+ # Setting this value to `false` or `nil` will omit sending the
24
+ # meta-field with your requests and use default routing behaviour.
25
+ #
26
+ # @return [String, NilClass, Boolean] The Elasticsearch `_routing` for the document
27
+ # @abstract
28
+ def routing
29
+ end
30
+
31
+ def attributes
32
+ {}
33
+ end
34
+
35
+ def to_h
36
+ {
37
+ _id: id,
38
+ }.tap do |hash|
39
+ hash[:_routing] = routing if routing
40
+ end
41
+ end
42
+ end
43
+ end
@@ -92,5 +92,19 @@ module Esse
92
92
  block.call(entries, *args, **kwargs)
93
93
  end
94
94
  end
95
+
96
+ # Wrap collection data into serialized documents
97
+ #
98
+ # Example:
99
+ # GeosIndex.documents(id: 1).first
100
+ #
101
+ # @return [Enumerator] All serialized entries
102
+ def documents(*args, **kargs)
103
+ Enumerator.new do |yielder|
104
+ each_serialized_batch(*args, **kargs) do |documents, *_inner_args, **_inner_kargs|
105
+ documents.each { |document| yielder.yield(document) }
106
+ end
107
+ end
108
+ end
95
109
  end
96
110
  end
data/lib/esse/version.rb CHANGED
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Esse
4
- VERSION = '0.1.2'
4
+ VERSION = '0.1.3'
5
5
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: esse
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.2
4
+ version: 0.1.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Marcos G. Zimmermann
8
8
  autorequire:
9
9
  bindir: exec
10
10
  cert_chain: []
11
- date: 2022-01-31 00:00:00.000000000 Z
11
+ date: 2022-03-21 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: elasticsearch
@@ -260,6 +260,7 @@ files:
260
260
  - lib/esse/cluster.rb
261
261
  - lib/esse/config.rb
262
262
  - lib/esse/core.rb
263
+ - lib/esse/document.rb
263
264
  - lib/esse/errors.rb
264
265
  - lib/esse/events.rb
265
266
  - lib/esse/events/bus.rb