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