esql-enrich-data.asciidoc 3.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145
  1. [[esql-enrich-data]]
  2. === Data enrichment
  3. ++++
  4. <titleabbrev>Data enrichment</titleabbrev>
  5. ++++
  6. The {esql} <<esql-enrich>> processing command combines, at query-time, data from
  7. one or more source indexes with field-value combinations found in {es} enrich
  8. indexes.
  9. For example, you can use `ENRICH` to:
  10. * Identify web services or vendors based on known IP addresses
  11. * Add product information to retail orders based on product IDs
  12. * Supplement contact information based on an email address
  13. [discrete]
  14. [[esql-how-enrich-works]]
  15. ==== How the `ENRICH` command works
  16. The `ENRICH` command adds new columns to a table, with data from {es} indices.
  17. It requires a few special components:
  18. image::images/esql/esql-enrich.png[align="center"]
  19. [[esql-enrich-policy]]
  20. Enrich policy::
  21. +
  22. --
  23. A set of configuration options used to add the right enrich data to the input
  24. table.
  25. An enrich policy contains:
  26. include::../ingest/enrich.asciidoc[tag=enrich-policy-fields]
  27. After <<esql-create-enrich-policy,creating a policy>>, it must be
  28. <<esql-execute-enrich-policy,executed>> before it can be used. Executing an
  29. enrich policy uses data from the policy's source indices to create a streamlined
  30. system index called the _enrich index_. The `ENRICH` command uses this index to
  31. match and enrich an input table.
  32. --
  33. [[esql-source-index]]
  34. Source index::
  35. An index which stores enrich data that the `ENRICH` command can add to input
  36. tables. You can create and manage these indices just like a regular {es} index.
  37. You can use multiple source indices in an enrich policy. You also can use the
  38. same source index in multiple enrich policies.
  39. [[esql-enrich-index]]
  40. Enrich index::
  41. +
  42. --
  43. A special system index tied to a specific enrich policy.
  44. Directly matching rows from input tables to documents in source indices could be
  45. slow and resource intensive. To speed things up, the `ENRICH` command uses an
  46. enrich index.
  47. include::../ingest/enrich.asciidoc[tag=enrich-index]
  48. --
  49. [discrete]
  50. [[esql-set-up-enrich-policy]]
  51. ==== Set up an enrich policy
  52. To start using `ENRICH`, follow these steps:
  53. . Check the <<enrich-prereqs, prerequisites>>.
  54. . <<esql-create-enrich-source-index>>.
  55. . <<esql-create-enrich-policy>>.
  56. . <<esql-execute-enrich-policy>>.
  57. . <<esql-use-enrich>>
  58. Once you have enrich policies set up, you can <<esql-update-enrich-data,update
  59. your enrich data>> and <<esql-update-enrich-policies, update your enrich
  60. policies>>.
  61. [discrete]
  62. [IMPORTANT]
  63. ====
  64. The `ENRICH` command performs several operations and may impact the speed of
  65. your query.
  66. [discrete]
  67. ====
  68. [discrete]
  69. [[esql-enrich-prereqs]]
  70. ==== Prerequisites
  71. include::{es-ref-dir}/ingest/apis/enrich/put-enrich-policy.asciidoc[tag=enrich-policy-api-prereqs]
  72. [discrete]
  73. [[esql-create-enrich-source-index]]
  74. ==== Add enrich data
  75. include::../ingest/enrich.asciidoc[tag=create-enrich-source-index]
  76. [discrete]
  77. [[esql-create-enrich-policy]]
  78. ==== Create an enrich policy
  79. include::../ingest/enrich.asciidoc[tag=create-enrich-policy]
  80. [discrete]
  81. [[esql-execute-enrich-policy]]
  82. ==== Execute the enrich policy
  83. include::../ingest/enrich.asciidoc[tag=execute-enrich-policy1]
  84. image::images/esql/esql-enrich-policy.png[align="center"]
  85. include::../ingest/enrich.asciidoc[tag=execute-enrich-policy2]
  86. [discrete]
  87. [[esql-use-enrich]]
  88. ==== Use the enrich policy
  89. After the policy has been executed, you can use the <<esql-enrich,`ENRICH`
  90. command>> to enrich your data.
  91. image::images/esql/esql-enrich-command.png[align="center",width=50%]
  92. include::processing-commands/enrich.asciidoc[tag=examples]
  93. [discrete]
  94. [[esql-update-enrich-data]]
  95. ==== Update an enrich index
  96. include::{es-ref-dir}/ingest/apis/enrich/execute-enrich-policy.asciidoc[tag=update-enrich-index]
  97. [discrete]
  98. [[esql-update-enrich-policies]]
  99. ==== Update an enrich policy
  100. include::../ingest/enrich.asciidoc[tag=update-enrich-policy]
  101. ==== Limitations
  102. // tag::limitations[]
  103. The {esql} `ENRICH` command only supports enrich policies of type `match`.
  104. Furthermore, `ENRICH` only supports enriching on a column of type `keyword`.
  105. // end::limitations[]