enrich.asciidoc 7.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222
  1. [role="xpack"]
  2. [testenv="basic"]
  3. [[ingest-enriching-data]]
  4. == Enrich your data
  5. You can use the <<enrich-processor,enrich processor>> to add data from your
  6. existing indices to incoming documents during ingest.
  7. For example, you can use the enrich processor to:
  8. * Identify web services or vendors based on known IP addresses
  9. * Add product information to retail orders based on product IDs
  10. * Supplement contact information based on an email address
  11. * Add postal codes based on user coordinates
  12. [discrete]
  13. [[how-enrich-works]]
  14. === How the enrich processor works
  15. Most processors are self-contained and only change _existing_ data in incoming
  16. documents.
  17. image::images/ingest/ingest-process.svg[align="center"]
  18. The enrich processor adds _new_ data to incoming documents and requires a few
  19. special components:
  20. image::images/ingest/enrich/enrich-process.svg[align="center"]
  21. [[enrich-policy]]
  22. enrich policy::
  23. +
  24. --
  25. A set of configuration options used to add the right enrich data to the right
  26. incoming documents.
  27. An enrich policy contains:
  28. // tag::enrich-policy-fields[]
  29. * A list of one or more _source indices_ which store enrich data as documents
  30. * The _policy type_ which determines how the processor matches the enrich data
  31. to incoming documents
  32. * A _match field_ from the source indices used to match incoming documents
  33. * _Enrich fields_ containing enrich data from the source indices you want to add
  34. to incoming documents
  35. // end::enrich-policy-fields[]
  36. Before it can be used with an enrich processor, an enrich policy must be
  37. <<execute-enrich-policy-api,executed>>. When executed, an enrich policy uses
  38. enrich data from the policy's source indices to create a streamlined system
  39. index called the _enrich index_. The processor uses this index to match and
  40. enrich incoming documents.
  41. --
  42. [[source-index]]
  43. source index::
  44. An index which stores enrich data you'd like to add to incoming documents. You
  45. can create and manage these indices just like a regular {es} index. You can use
  46. multiple source indices in an enrich policy. You also can use the same source
  47. index in multiple enrich policies.
  48. [[enrich-index]]
  49. enrich index::
  50. +
  51. --
  52. A special system index tied to a specific enrich policy.
  53. Directly matching incoming documents to documents in source indices could be
  54. slow and resource intensive. To speed things up, the enrich processor uses an
  55. enrich index.
  56. Enrich indices contain enrich data from source indices but have a few special
  57. properties to help streamline them:
  58. * They are system indices, meaning they're managed internally by {es} and only
  59. intended for use with enrich processors.
  60. * They always begin with `.enrich-*`.
  61. * They are read-only, meaning you can't directly change them.
  62. * They are <<indices-forcemerge,force merged>> for fast retrieval.
  63. --
  64. [role="xpack"]
  65. [testenv="basic"]
  66. [[enrich-setup]]
  67. === Set up an enrich processor
  68. To set up an enrich processor, follow these steps:
  69. . Check the <<enrich-prereqs, prerequisites>>.
  70. . <<create-enrich-source-index>>.
  71. . <<create-enrich-policy>>.
  72. . <<execute-enrich-policy>>.
  73. . <<add-enrich-processor>>.
  74. . <<ingest-enrich-docs>>.
  75. Once you have an enrich processor set up,
  76. you can <<update-enrich-data,update your enrich data>>
  77. and <<update-enrich-policies, update your enrich policies>>.
  78. [IMPORTANT]
  79. ====
  80. The enrich processor performs several operations and may impact the speed of
  81. your ingest pipeline.
  82. We strongly recommend testing and benchmarking your enrich processors
  83. before deploying them in production.
  84. We do not recommend using the enrich processor to append real-time data.
  85. The enrich processor works best with reference data
  86. that doesn't change frequently.
  87. ====
  88. [discrete]
  89. [[enrich-prereqs]]
  90. ==== Prerequisites
  91. include::{es-repo-dir}/ingest/apis/enrich/put-enrich-policy.asciidoc[tag=enrich-policy-api-prereqs]
  92. [[create-enrich-source-index]]
  93. ==== Add enrich data
  94. To begin, add documents to one or more source indices. These documents should
  95. contain the enrich data you eventually want to add to incoming documents.
  96. You can manage source indices just like regular {es} indices using the
  97. <<docs,document>> and <<indices,index>> APIs.
  98. You also can set up {beats-ref}/getting-started.html[{beats}], such as a
  99. {filebeat-ref}/filebeat-installation-configuration.html[{filebeat}], to
  100. automatically send and index documents to your source indices. See
  101. {beats-ref}/getting-started.html[Getting started with {beats}].
  102. [[create-enrich-policy]]
  103. ==== Create an enrich policy
  104. After adding enrich data to your source indices, use the
  105. <<put-enrich-policy-api,create enrich policy API>> to create an enrich policy.
  106. [WARNING]
  107. ====
  108. Once created, you can't update or change an enrich policy.
  109. See <<update-enrich-policies>>.
  110. ====
  111. [[execute-enrich-policy]]
  112. ==== Execute the enrich policy
  113. Once the enrich policy is created, you can execute it using the
  114. <<execute-enrich-policy-api,execute enrich policy API>> to create an
  115. <<enrich-index,enrich index>>.
  116. image::images/ingest/enrich/enrich-policy-index.svg[align="center"]
  117. include::apis/enrich/execute-enrich-policy.asciidoc[tag=execute-enrich-policy-def]
  118. [[add-enrich-processor]]
  119. ==== Add an enrich processor to an ingest pipeline
  120. Once you have source indices, an enrich policy, and the related enrich index in
  121. place, you can set up an ingest pipeline that includes an enrich processor for
  122. your policy.
  123. image::images/ingest/enrich/enrich-processor.svg[align="center"]
  124. Define an <<enrich-processor,enrich processor>> and add it to an ingest
  125. pipeline using the <<put-pipeline-api,create or update pipeline API>>.
  126. When defining the enrich processor, you must include at least the following:
  127. * The enrich policy to use.
  128. * The field used to match incoming documents to the documents in your enrich index.
  129. * The target field to add to incoming documents. This target field contains the
  130. match and enrich fields specified in your enrich policy.
  131. You also can use the `max_matches` option to set the number of enrich documents
  132. an incoming document can match. If set to the default of `1`, data is added to
  133. an incoming document's target field as a JSON object. Otherwise, the data is
  134. added as an array.
  135. See <<enrich-processor>> for a full list of configuration options.
  136. You also can add other <<processors,processors>> to your ingest pipeline.
  137. [[ingest-enrich-docs]]
  138. ==== Ingest and enrich documents
  139. You can now use your ingest pipeline to enrich and index documents.
  140. image::images/ingest/enrich/enrich-process.svg[align="center"]
  141. Before implementing the pipeline in production, we recommend indexing a few test
  142. documents first and verifying enrich data was added correctly using the
  143. <<docs-get,get API>>.
  144. [[update-enrich-data]]
  145. ==== Update an enrich index
  146. include::{es-repo-dir}/ingest/apis/enrich/execute-enrich-policy.asciidoc[tag=update-enrich-index]
  147. If wanted, you can <<docs-reindex,reindex>>
  148. or <<docs-update-by-query,update>> any already ingested documents
  149. using your ingest pipeline.
  150. [[update-enrich-policies]]
  151. ==== Update an enrich policy
  152. // tag::update-enrich-policy[]
  153. Once created, you can't update or change an enrich policy.
  154. Instead, you can:
  155. . Create and <<execute-enrich-policy-api,execute>> a new enrich policy.
  156. . Replace the previous enrich policy
  157. with the new enrich policy
  158. in any in-use enrich processors.
  159. . Use the <<delete-enrich-policy-api, delete enrich policy>> API
  160. to delete the previous enrich policy.
  161. // end::update-enrich-policy[]
  162. include::geo-match-enrich-policy-type-ex.asciidoc[]
  163. include::match-enrich-policy-type-ex.asciidoc[]