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 +4 -4
- data/lib/esse/document.rb +43 -0
- data/lib/esse/object_document_mapper.rb +14 -0
- data/lib/esse/version.rb +1 -1
- metadata +3 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: '0785bd8298d822b9778cbbbd98e8ae6b97063d0c18e11da57266e6cb8129c08a'
|
4
|
+
data.tar.gz: ea927277c5d497bf37127f4c0467253d6163cbc2e011cee9af2095a38162e339
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
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
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.
|
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-
|
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
|