enrich.asciidoc 9.3 KB

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