File tree Expand file tree Collapse file tree 1 file changed +47
-0
lines changed Expand file tree Collapse file tree 1 file changed +47
-0
lines changed Original file line number Diff line number Diff line change @@ -99,6 +99,53 @@ PUT _ingest/pipeline/attachment
99
99
NOTE: Extracting contents from binary data is a resource intensive operation and
100
100
consumes a lot of resources. It is highly recommended to run pipelines
101
101
using this processor in a dedicated ingest node.
102
+
103
+ [[ingest-attachment-cbor]]
104
+ ==== Use the attachment processor with CBOR
105
+
106
+ To avoid encoding and decoding JSON to base64, you can instead pass CBOR data to
107
+ the attachment processor. For example, the following request creates the
108
+ `cbor-attachment` pipeline, which uses the attachment processor.
109
+
110
+ [source,console]
111
+ ----
112
+ PUT _ingest/pipeline/cbor-attachment
113
+ {
114
+ "description" : "Extract attachment information",
115
+ "processors" : [
116
+ {
117
+ "attachment" : {
118
+ "field" : "data"
119
+ }
120
+ }
121
+ ]
122
+ }
123
+ ----
124
+
125
+ The following Python script passes CBOR data to an HTTP indexing request that
126
+ includes the `cbor-attachment` pipeline. The HTTP request headers use a
127
+ a `content-type` of `application/cbor`.
128
+
129
+ NOTE: Not all {es} clients support custom HTTP request headers.
130
+
131
+ [source,python]
132
+ ----
133
+ import cbor2
134
+ import requests
135
+
136
+ file = 'my-file'
137
+ headers = {'content-type': 'application/cbor'}
138
+
139
+ with open(file, 'rb') as f:
140
+ doc = {
141
+ 'data': f.read()
142
+ }
143
+ requests.put(
144
+ 'http://localhost:9200/my-index-000001/_doc/my_id?pipeline=cbor-attachment',
145
+ data=cbor2.dumps(doc),
146
+ headers=headers
147
+ )
148
+ ----
102
149
103
150
[[ingest-attachment-extracted-chars]]
104
151
==== Limit the number of extracted chars
You can’t perform that action at this time.
0 commit comments