原英文版地址: https://www.elastic.co/guide/en/elasticsearch/reference/7.7/ingest-enriching-data.html, 原文档版权归 www.elastic.co 所有
本地英文版地址: ../en/ingest-enriching-data.html

Enrich your dataedit

You can use the enrich processor to add data from your existing indices to incoming documents during ingest.

For example, you can use the enrich processor to:

  • Identify web services or vendors based on known IP addresses
  • Add product information to retail orders based on product IDs
  • Supplement contact information based on an email address
  • Add postal codes based on user coordinates

How the enrich processor worksedit

An ingest pipeline changes documents before they are actually indexed. You can think of an ingest pipeline as an assembly line made up of a series of workers, called processors. Each processor makes specific changes, like lowercasing field values, to incoming documents before moving on to the next. When all the processors in a pipeline are done, the finished document is added to the target index.

ingest process

Most processors are self-contained and only change existing data in incoming documents. But the enrich processor adds new data to incoming documents and requires a few special components:

enrich process
enrich policy

A set of configuration options used to add the right enrich data to the right incoming documents.

An enrich policy contains:

  • A list of one or more source indices which store enrich data as documents
  • The policy type which determines how the processor matches the enrich data to incoming documents
  • A match field from the source indices used to match incoming documents
  • Enrich fields containing enrich data from the source indices you want to add to incoming documents

Before it can be used with an enrich processor, an enrich policy must be executed. When executed, an enrich policy uses enrich data from the policy’s source indices to create a streamlined system index called the enrich index. The processor uses this index to match and enrich incoming documents.

See Enrich policy definition for a full list of enrich policy types and configuration options.

source index
An index which stores enrich data you’d like to add to incoming documents. You can create and manage these indices just like a regular Elasticsearch index. You can use multiple source indices in an enrich policy. You also can use the same source index in multiple enrich policies.
enrich index

A special system index tied to a specific enrich policy.

Directly matching incoming documents to documents in source indices could be slow and resource intensive. To speed things up, the enrich processor uses an enrich index.

Enrich indices contain enrich data from source indices but have a few special properties to help streamline them:

  • They are system indices, meaning they’re managed internally by Elasticsearch and only intended for use with enrich processors.
  • They always begin with .enrich-*.
  • They are read-only, meaning you can’t directly change them.
  • They are force merged for fast retrieval.