Add ingest-attachment-with-arrays section to ingest attachments doc
Added a new section detailing how to use the attachment processor within an array. This reverts commit #22296 and instead links to the foreach processor.
This commit is contained in:
parent
5c8232c03b
commit
d404ee3533
|
@ -106,4 +106,54 @@ NOTE: Extracting contents from binary data is a resource intensive operation and
|
||||||
consumes a lot of resources. It is highly recommended to run pipelines
|
consumes a lot of resources. It is highly recommended to run pipelines
|
||||||
using this processor in a dedicated ingest node.
|
using this processor in a dedicated ingest node.
|
||||||
|
|
||||||
NOTE: To process an array of attachments the {ref}/foreach-processor.html[foreach processor] is required.
|
[[ingest-attachment-with-arrays]]
|
||||||
|
==== Using the Attachment Processor with arrays
|
||||||
|
|
||||||
|
To use the attachment processor within an array of attachments the
|
||||||
|
{ref}/foreach-processor.html[foreach processor] is required. This
|
||||||
|
enables the attachment processor to be run on the individual elements
|
||||||
|
of the array.
|
||||||
|
|
||||||
|
For example, given the following source:
|
||||||
|
|
||||||
|
[source,js]
|
||||||
|
--------------------------------------------------
|
||||||
|
{
|
||||||
|
"attachments" : [
|
||||||
|
{
|
||||||
|
"filename" : "ipsum.txt",
|
||||||
|
"data" : "dGhpcyBpcwpqdXN0IHNvbWUgdGV4dAo="
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"filename" : "test.txt",
|
||||||
|
"data" : "VGhpcyBpcyBhIHRlc3QK"
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
|
--------------------------------------------------
|
||||||
|
|
||||||
|
In this case, we want to process the data field in each element
|
||||||
|
of the attachments field and insert
|
||||||
|
the properties into the document so the following `foreach`
|
||||||
|
processor is used:
|
||||||
|
|
||||||
|
[source,js]
|
||||||
|
--------------------------------------------------
|
||||||
|
{
|
||||||
|
"foreach": {
|
||||||
|
"field": "attachments",
|
||||||
|
"processor": {
|
||||||
|
"attachment": {
|
||||||
|
"target_field": "_ingest._value.attachment",
|
||||||
|
"field": "_ingest._value.data"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
--------------------------------------------------
|
||||||
|
Note that the `target_field` needs to be set, otherwise the
|
||||||
|
default value is used which is a top level field `attachment`. The
|
||||||
|
properties on this top level field will contain the value of the
|
||||||
|
first attachment only. However, by specifying the
|
||||||
|
`target_field` on to a value on `_ingest._value` it will correctly
|
||||||
|
associate the properties with the correct attachment.
|
||||||
|
|
|
@ -1166,6 +1166,10 @@ In this example, if the `remove` processor does fail, then
|
||||||
the array elements that have been processed thus far will
|
the array elements that have been processed thus far will
|
||||||
be updated.
|
be updated.
|
||||||
|
|
||||||
|
Another advanced example can be found in {plugins}/using-ingest-attachment.html[attachment processor documentation].
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
[[grok-processor]]
|
[[grok-processor]]
|
||||||
=== Grok Processor
|
=== Grok Processor
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue