ingest-attachment.asciidoc 3.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103
  1. [[ingest-attachment]]
  2. === Ingest Attachment Processor Plugin
  3. The ingest attachment plugin lets Elasticsearch extract file attachments in common formats (such as PPT, XLS, and PDF) by
  4. using the Apache text extraction library http://lucene.apache.org/tika/[Tika].
  5. You can use the ingest attachment plugin as a replacement for the mapper attachment plugin.
  6. The source field must be a base64 encoded binary. If you do not want to incur
  7. the overhead of converting back and forth between base64, you can use the CBOR
  8. format instead of JSON and specify the field as a bytes array instead of a string
  9. representation. The processor will skip the base64 decoding then.
  10. [[ingest-attachment-install]]
  11. [float]
  12. ==== Installation
  13. This plugin can be installed using the plugin manager:
  14. [source,sh]
  15. ----------------------------------------------------------------
  16. sudo bin/elasticsearch-plugin install ingest-attachment
  17. ----------------------------------------------------------------
  18. The plugin must be installed on every node in the cluster, and each node must
  19. be restarted after installation.
  20. [[ingest-attachment-remove]]
  21. [float]
  22. ==== Removal
  23. The plugin can be removed with the following command:
  24. [source,sh]
  25. ----------------------------------------------------------------
  26. sudo bin/elasticsearch-plugin remove ingest-attachment
  27. ----------------------------------------------------------------
  28. The node must be stopped before removing the plugin.
  29. [[using-ingest-attachment]]
  30. ==== Using the Attachment Processor in a Pipeline
  31. [[ingest-attachment-options]]
  32. .Attachment options
  33. [options="header"]
  34. |======
  35. | Name | Required | Default | Description
  36. | `field` | yes | - | The field to get the base64 encoded field from
  37. | `target_field` | no | attachment | The field that will hold the attachment information
  38. | `indexed_chars` | no | 100000 | The number of chars being used for extraction to prevent huge fields. Use `-1` for no limit.
  39. | `properties` | no | all | Properties to select to be stored. Can be `content`, `title`, `name`, `author`, `keywords`, `date`, `content_type`, `content_length`, `language`
  40. |======
  41. For example, this:
  42. [source,js]
  43. --------------------------------------------------
  44. PUT _ingest/pipeline/attachment
  45. {
  46. "description" : "Extract attachment information",
  47. "processors" : [
  48. {
  49. "attachment" : {
  50. "field" : "data"
  51. }
  52. }
  53. ]
  54. }
  55. PUT my_index/my_type/my_id?pipeline=attachment
  56. {
  57. "data": "e1xydGYxXGFuc2kNCkxvcmVtIGlwc3VtIGRvbG9yIHNpdCBhbWV0DQpccGFyIH0="
  58. }
  59. GET my_index/my_type/my_id
  60. --------------------------------------------------
  61. // CONSOLE
  62. Returns this:
  63. [source,js]
  64. --------------------------------------------------
  65. {
  66. "found": true,
  67. "_index": "my_index",
  68. "_type": "my_type",
  69. "_id": "my_id",
  70. "_version": 1,
  71. "_source": {
  72. "data": "e1xydGYxXGFuc2kNCkxvcmVtIGlwc3VtIGRvbG9yIHNpdCBhbWV0DQpccGFyIH0=",
  73. "attachment": {
  74. "content_type": "application/rtf",
  75. "language": "ro",
  76. "content": "Lorem ipsum dolor sit amet",
  77. "content_length": 28
  78. }
  79. }
  80. }
  81. --------------------------------------------------
  82. // TESTRESPONSE
  83. NOTE: Extracting contents from binary data is a resource intensive operation and
  84. consumes a lot of resources. It is highly recommended to run pipelines
  85. using this processor in a dedicated ingest node.