2016-02-09 08:57:05 -05:00
[[ingest-attachment]]
2016-02-11 20:40:32 -05:00
=== Ingest Attachment Processor Plugin
2016-02-09 08:57:05 -05:00
2016-03-04 01:49:31 -05:00
The ingest attachment plugin lets Elasticsearch extract file attachments in common formats (such as PPT, XLS, and PDF) by
2016-02-09 08:57:05 -05:00
using the Apache text extraction library http://lucene.apache.org/tika/[Tika].
2016-03-04 01:49:31 -05:00
You can use the ingest attachment plugin as a replacement for the mapper attachment plugin.
2016-02-09 08:57:05 -05:00
2016-04-11 08:14:56 -04:00
The source field must be a base64 encoded binary. If you do not want to incur
the overhead of converting back and forth between base64, you can use the CBOR
format instead of JSON and specify the field as a bytes array instead of a string
representation. The processor will skip the base64 decoding then.
2016-02-09 08:57:05 -05:00
2016-06-08 15:55:59 -04:00
[[ingest-attachment-install]]
[float]
==== Installation
This plugin can be installed using the plugin manager:
[source,sh]
----------------------------------------------------------------
sudo bin/elasticsearch-plugin install ingest-attachment
----------------------------------------------------------------
The plugin must be installed on every node in the cluster, and each node must
be restarted after installation.
2016-09-19 09:04:29 -04:00
This plugin can be downloaded for <<plugin-management-custom-url,offline install>> from
2016-10-07 13:17:10 -04:00
{plugin_url}/ingest-attachment/ingest-attachment-{version}.zip.
2016-09-12 09:34:44 -04:00
2016-06-08 15:55:59 -04:00
[[ingest-attachment-remove]]
[float]
==== Removal
The plugin can be removed with the following command:
[source,sh]
----------------------------------------------------------------
sudo bin/elasticsearch-plugin remove ingest-attachment
----------------------------------------------------------------
The node must be stopped before removing the plugin.
[[using-ingest-attachment]]
==== Using the Attachment Processor in a Pipeline
2016-02-09 08:57:05 -05:00
[[ingest-attachment-options]]
.Attachment options
[options="header"]
|======
| Name | Required | Default | Description
2016-04-20 12:00:11 -04:00
| `field` | yes | - | The field to get the base64 encoded field from
2016-02-09 08:57:05 -05:00
| `target_field` | no | attachment | The field that will hold the attachment information
| `indexed_chars` | no | 100000 | The number of chars being used for extraction to prevent huge fields. Use `-1` for no limit.
2016-04-20 12:00:11 -04:00
| `properties` | no | all | Properties to select to be stored. Can be `content`, `title`, `name`, `author`, `keywords`, `date`, `content_type`, `content_length`, `language`
2016-02-09 08:57:05 -05:00
|======
2016-08-10 11:12:41 -04:00
For example, this:
2016-02-09 08:57:05 -05:00
[source,js]
--------------------------------------------------
2016-08-10 11:12:41 -04:00
PUT _ingest/pipeline/attachment
2016-02-09 08:57:05 -05:00
{
2016-08-10 11:12:41 -04:00
"description" : "Extract attachment information",
2016-02-09 08:57:05 -05:00
"processors" : [
{
"attachment" : {
2016-04-20 12:00:11 -04:00
"field" : "data"
2016-02-09 08:57:05 -05:00
}
}
]
}
2016-08-10 11:12:41 -04:00
PUT my_index/my_type/my_id?pipeline=attachment
{
"data": "e1xydGYxXGFuc2kNCkxvcmVtIGlwc3VtIGRvbG9yIHNpdCBhbWV0DQpccGFyIH0="
}
GET my_index/my_type/my_id
--------------------------------------------------
// CONSOLE
Returns this:
[source,js]
--------------------------------------------------
{
"found": true,
"_index": "my_index",
"_type": "my_type",
"_id": "my_id",
"_version": 1,
"_source": {
"data": "e1xydGYxXGFuc2kNCkxvcmVtIGlwc3VtIGRvbG9yIHNpdCBhbWV0DQpccGFyIH0=",
"attachment": {
"content_type": "application/rtf",
"language": "ro",
"content": "Lorem ipsum dolor sit amet",
2016-08-10 13:07:22 -04:00
"content_length": 28
2016-08-10 11:12:41 -04:00
}
}
}
2016-02-09 08:57:05 -05:00
--------------------------------------------------
2016-08-10 11:12:41 -04:00
// TESTRESPONSE
2016-02-09 08:57:05 -05:00
NOTE: Extracting contents from binary data is a resource intensive operation and
consumes a lot of resources. It is highly recommended to run pipelines
using this processor in a dedicated ingest node.