Browse Source

[DOCS] Add high-level docs for enrich processor and policies (#49194)

* [DOCS] Add high-level docs for enrich policies

* fix typos

* fix typo

* add warning for enrich policy changes

* add addtl cross-links to execute API docs

* Reword match and geo_match policy example headings
James Rodewig 5 years ago
parent
commit
c9e9685bfd

File diff suppressed because it is too large
+ 17 - 0
docs/reference/images/ingest/enrich/enrich-policy-index.svg


File diff suppressed because it is too large
+ 17 - 0
docs/reference/images/ingest/enrich/enrich-process.svg


File diff suppressed because it is too large
+ 17 - 0
docs/reference/images/ingest/enrich/enrich-processor.svg


File diff suppressed because it is too large
+ 18 - 0
docs/reference/images/ingest/ingest-process.svg


+ 2 - 1
docs/reference/ingest/apis/enrich/delete-enrich-policy.asciidoc

@@ -6,7 +6,8 @@
 <titleabbrev>Delete enrich policy</titleabbrev>
 ++++
 
-Deletes an existing enrich policy and its enrich index.
+Deletes an existing <<enrich-policy,enrich policy>> and its
+<<enrich-index,enrich index>>.
 
 ////
 [source,console]

+ 1 - 1
docs/reference/ingest/apis/enrich/enrich-stats.asciidoc

@@ -7,7 +7,7 @@
 ++++
 
 Returns <<coordinating-node,enrich coordinator>> statistics
-and information about enrich policies
+and information about <<enrich-policy,enrich policies>>
 that are currently executing.
 
 [source,console]

+ 2 - 2
docs/reference/ingest/apis/enrich/execute-enrich-policy.asciidoc

@@ -6,7 +6,7 @@
 <titleabbrev>Execute enrich policy</titleabbrev>
 ++++
 
-Executes an existing enrich policy.
+Executes an existing <<enrich-policy,enrich policy>>.
 
 ////
 
@@ -87,7 +87,7 @@ Avoid using enrich indices for other purposes.
 Once created, you cannot update 
 or index documents to an enrich index.
 Instead, update your source indices
-and execute the enrich policy again.
+and <<execute-enrich-policy-api,execute>> the enrich policy again.
 This creates a new enrich index from your updated source indices
 and deletes the previous enrich index.
 // end::update-enrich-index[]

+ 1 - 1
docs/reference/ingest/apis/enrich/get-enrich-policy.asciidoc

@@ -6,7 +6,7 @@
 <titleabbrev>Get enrich policy</titleabbrev>
 ++++
 
-Returns information about an enrich policy.
+Returns information about an <<enrich-policy,enrich policy>>.
 
 ////
 [source,console]

+ 3 - 2
docs/reference/ingest/apis/enrich/index.asciidoc

@@ -1,9 +1,10 @@
 [[enrich-apis]]
 == Enrich APIs
 
-The following enrich APIs are available for managing enrich policies:
+The following enrich APIs are available for managing <<enrich-policy,enrich
+policies>>:
 
-* <<put-enrich-policy-api>> to add or update an enrich policy
+* <<put-enrich-policy-api>> to create or replace an enrich policy
 * <<delete-enrich-policy-api>> to delete an enrich policy
 * <<get-enrich-policy-api>> to return information about an enrich policy
 * <<execute-enrich-policy-api>> to execute an enrich policy

+ 11 - 259
docs/reference/ingest/apis/enrich/put-enrich-policy.asciidoc

@@ -65,29 +65,15 @@ If you use {es} {security-features}, you must have:
 ==== {api-description-title}
 
 Use the put enrich policy API
-to create a new enrich policy.
-
-// tag::enrich-policy-def[]
-An *enrich policy* is a set of rules the enrich processor uses
-to append the appropriate data to incoming documents.
-An enrich policy contains:
-
-* The *policy type*,
-  which determines how the processor enriches incoming documents
-* A list of source indices
-* The *match field* used to match incoming documents
-* *Enrich fields* appended to incoming documents
-  from matching documents
-// end::enrich-policy-def[]
-
-
-===== Update an enrich policy
+to create a new <<enrich-policy,enrich policy>>.
 
 // tag::update-enrich-policy[]
-You cannot update an existing enrich policy.
+[WARNING]
+====
+Once created, you can't update or change an enrich policy.
 Instead, you can:
 
-.   Create and execute a new enrich policy.
+.   Create and <<execute-enrich-policy-api,execute>> a new enrich policy.
 
 .   Replace the previous enrich policy
     with the new enrich policy
@@ -95,6 +81,7 @@ Instead, you can:
 
 .   Use the <<delete-enrich-policy-api, delete enrich policy>> API
     to delete the previous enrich policy.
+====
 // end::update-enrich-policy[]
 
 
@@ -112,244 +99,9 @@ include::{docdir}/rest-api/common-parms.asciidoc[tag=enrich-policy]
 `<policy-type>`::
 +
 --
-(Required, enrich policy object)
-The parameter key is the enrich policy type.
-The enrich policy type indicates
-how the enrich processor matches incoming documents 
-to documents in the enrich index.
-
-Valid key values are:
-
-`match`::
-Match documents in the enrich index
-using a <<query-dsl-term-query,term query>> for the `match_field`.
-See <<enrich-setup>> for an example.
-
-`geo_match`::
-Match documents in the enrich index
-using a <<query-dsl-geo-shape-query,`geo_shape` query>> for the `match_field`.
-See <<put-enrich-policy-geo-match-ex>> for an example.
-
-The parameter value is the enrich policy.
-The enrich policy is a set of rules
-used to create an <<execute-enrich-policy,enrich index>>.
-The enrich processor also uses these rules
-to append field data to incoming documents.
-
-Parameters include:
-
-`indices`::
-(Required, array of strings)
-Source indices used to create the enrich index.
-
-`query`::
-(Optional, string)
-Query type used to find and select documents in the enrich index.
-Valid value is <<query-dsl-match-all-query,`match_all`>> (default).
-
-`match_field`::
-(Required, string)
-Field used to match incoming documents 
-to documents in the enrich index.
-
-`enrich_fields`::
-(Required, Array of string)
-Fields appended to incoming documents
-from matching documents in the enrich index.
---
-
-[[put-enrich-policy-api-example]]
-==== {api-examples-title}
-
-[[put-enrich-policy-geo-match-ex]]
-===== `geo_match` policy type
-
-You can use the `geo_match` enrich policy type
-to enrich incoming documents
-based on matching geo_shapes.
-For example,
-you can add postal codes
-to incoming documents
-based on a set of coordinates.
-
-To see how the `geo_match` policy type works,
-try the following example.
-
-Use the <<indices-create-index, create index API>>
-to create a source index.
-The field mappings for the source index
-must contain:
-
-* A <<geo-shape,`geo_shape`>> field
-  which the enrich processor can use to match incoming documents
-* One or more enrich fields
-  you'd like to append to incoming documents
-
-[source,console]
-----
-PUT /postal_codes
-{
-    "mappings": {
-        "properties": {
-            "location": {
-                "type": "geo_shape"
-            },
-            "postal_code": {
-                "type": "keyword"
-            } 
-        }
-    }
-}
-----
+(Required, <<enrich-policy-definition,enrich policy>> object)
+Enrich policy used to match and add the right enrich data to
+the right incoming documents.
 
-Use the <<docs-index_,index API>>
-to index data to this source index.
-
-[source,console]
-----
-PUT /postal_codes/_doc/1?refresh=wait_for
-{
-    "location": {
-        "type": "envelope",
-        "coordinates": [[13.0, 53.0], [14.0, 52.0]]
-    },
-    "postal_code": "96598"
-}
-----
-// TEST[continued]
-
-Use the put enrich policy API
-to create an enrich policy
-with the `geo_match` policy type.
-This policy must include:
-
-* One or more source indices
-* A `match_field`,
-  the `geo_shape` field from the source indices
-  used to match incoming documents
-* Enrich fields from the source indices
-  you'd like to append to incoming documents
-
-[source,console]
-----
-PUT /_enrich/policy/postal_policy
-{
-    "geo_match": {
-        "indices": "postal_codes",
-        "match_field": "location",
-        "enrich_fields": ["location","postal_code"]
-    }
-}
-----
-// TEST[continued]
-
-Use the <<execute-enrich-policy-api,execute enrich policy API>>
-to create an enrich index for the policy.
-
-include::execute-enrich-policy.asciidoc[tag=execute-enrich-policy-def]
-
-[source,console]
-----
-POST /_enrich/policy/postal_policy/_execute
-----
-// TEST[continued]
-
-Use the <<put-pipeline-api,put pipeline API>>
-to create an ingest pipeline.
-In the pipeline,
-add an <<enrich-processor,enrich processor>>
-that includes:
-
-* Your enrich policy
-* The `field` of incoming documents used
-  to match the geo_shape of documents from the enrich index.
-* The `target_field` used
-  to store appended enrich data for incoming documents.
-* The `shape_relation`,
- which indicates how the processor matches geo_shapes in incoming documents
- to geo_shapes in documents from the enrich index.
- See <<_spatial_relations>> for valid options and more information.
-
-[source,console]
-----
-PUT /_ingest/pipeline/postal_lookup
-{
-  "description": "Enrich postal codes",
-  "processors": [
-    {
-      "enrich": {
-        "policy_name": "postal_policy",
-        "field": "geo_location",
-        "target_field": "geo_data",
-        "shape_relation": "INTERSECTS"
-      }
-    }
-  ]
-}
-----
-// TEST[continued]
-
-Use the ingest pipeline
-to index a document.
-The incoming document
-should include the `field`
-specified in your enrich processor.
-
-[source,console]
-----
-PUT /users/_doc/0?pipeline=postal_lookup
-{
-    "first_name": "Mardy",
-    "last_name": "Brown",
-    "geo_location": "POINT (13.5 52.5)"
-}
-----
-// TEST[continued]
-
-To verify the enrich processor matched 
-and appended the appropriate field data,
-use the <<docs-get,get API>>
-to view the indexed document.
-
-[source,console]
-----
-GET /users/_doc/0
-----
-// TEST[continued]
-
-The API returns the following response:
-
-[source,console-result]
-----
-{
-  "found": true,
-  "_index": "users",
-  "_id": "0",
-  "_version": 1,
-  "_seq_no": 55,
-  "_primary_term": 1,
-  "_source": {
-    "geo_data": {
-      "location": {
-        "type": "envelope",
-        "coordinates": [[13.0, 53.0], [14.0, 52.0]]
-      },
-      "postal_code": "96598"
-    },
-    "first_name": "Mardy",
-    "last_name": "Brown",
-    "geo_location": "POINT (13.5 52.5)"
-  }
-}
-----
-// TESTRESPONSE[s/"_seq_no": \d+/"_seq_no" : $body._seq_no/ s/"_primary_term":1/"_primary_term" : $body._primary_term/]
-
-////
-[source,console]
---------------------------------------------------
-DELETE /_ingest/pipeline/postal_lookup
-
-DELETE /_enrich/policy/postal_policy
---------------------------------------------------
-// TEST[continued]
-////
+See <<enrich-policy-definition>> for object definition and parameters.
+--

+ 440 - 133
docs/reference/ingest/enrich.asciidoc

@@ -3,9 +3,8 @@
 [[ingest-enriching-data]]
 == Enrich your data
 
-You can use the <<enrich-processor,enrich processor>>
-to append data from existing indices
-to incoming documents during ingest.
+You can use the <<enrich-processor,enrich processor>> to add data from your
+existing indices to incoming documents during ingest.
 
 For example, you can use the enrich processor to:
 
@@ -14,13 +13,86 @@ For example, you can use the enrich processor to:
 * Supplement contact information based on an email address
 * Add postal codes based on user coordinates
 
+[discrete]
+[[how-enrich-works]]
+=== How the enrich processor works
 
-[float]
+An <<ingest,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 <<ingest-processors,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.
+
+image::images/ingest/ingest-process.svg[align="center"]
+
+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:
+
+image::images/ingest/enrich/enrich-process.svg[align="center"]
+
+[[enrich-policy]]
+enrich policy::
++
+--
+A set of configuration options used to add the right enrich data to the right
+incoming documents.
+
+An enrich policy contains:
+
+// tag::enrich-policy-fields[]
+* 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
+// end::enrich-policy-fields[]
+
+Before it can be used with an enrich processor, an enrich policy must be
+<<execute-enrich-policy-api,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]]
+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 {es} 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]]
+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 {es} 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 <<indices-forcemerge,force merged>> for fast retrieval.
+--
+
+[role="xpack"]
+[testenv="basic"]
 [[enrich-setup]]
 === Set up an enrich processor
 
-To set up an enrich processor and learn how it works,
-follow these steps:
+To set up an enrich processor, follow these steps:
 
 . Check the <<enrich-prereqs, prerequisites>>.
 . <<create-enrich-source-index>>.
@@ -31,8 +103,7 @@ follow these steps:
 
 Once you have an enrich processor set up,
 you can <<update-enrich-data,update your enrich data>>
-and <<update-enrich-policies, update your enrich policies>>
-using the <<enrich-apis,enrich APIs>>.
+and <<update-enrich-policies, update your enrich policies>>.
 
 [IMPORTANT]
 ====
@@ -53,20 +124,353 @@ that doesn't change frequently.
 
 include::{docdir}/ingest/apis/enrich/put-enrich-policy.asciidoc[tag=enrich-policy-api-prereqs]
 
-[float]
 [[create-enrich-source-index]]
-==== Create a source index
+==== Add enrich data
+
+To begin, add documents to one or more source indices. These documents should
+contain the enrich data you eventually want to add to incoming documents.
+
+You can manage source indices just like regular {es} indices using the
+<<docs,document>> and <<indices,index>> APIs.
+
+You also can set up {beats-ref}/getting-started.html[{beats}], such as a
+{filebeat-ref}/filebeat-getting-started.html[{filebeat}], to automatically send
+and index documents to your source indices. See
+{beats-ref}/getting-started.html[Getting started with {beats}].
+
+[[create-enrich-policy]]
+==== Create an enrich policy
+
+After adding enrich data to your source indices, you can
+<<enrich-policy-definition,define an enrich policy>>. When defining the enrich
+policy, you should include at least the following:
+
+include::enrich.asciidoc[tag=enrich-policy-fields]
+
+You can use this definition to create the enrich policy with the
+<<put-enrich-policy-api,put enrich policy API>>.
+
+include::apis/enrich/put-enrich-policy.asciidoc[tag=update-enrich-policy]
+
+[[execute-enrich-policy]]
+==== Execute the enrich policy
+
+Once the enrich policy is created, you can execute it using the
+<<execute-enrich-policy-api,execute enrich policy API>> to create an
+<<enrich-index,enrich index>>.
+
+image::images/ingest/enrich/enrich-policy-index.svg[align="center"]
+
+include::apis/enrich/execute-enrich-policy.asciidoc[tag=execute-enrich-policy-def]
+
+[[add-enrich-processor]]
+==== Add an enrich processor to an ingest pipeline
+
+Once you have source indices, an enrich policy, and the related enrich index in
+place, you can set up an ingest pipeline that includes an enrich processor for
+your policy.
+
+image::images/ingest/enrich/enrich-processor.svg[align="center"]
+
+Define an <<enrich-processor,enrich processor>> and add it to an ingest
+pipeline using the <<put-pipeline-api,put pipeline API>>.
+
+When defining the enrich processor, you must include at least the following:
+
+* The enrich policy to use.
+* The field used to match incoming documents to the documents in your enrich index.
+* The target field to add to incoming documents. This target field contains the
+enrich fields specified in your enrich policy.
+
+You also can use the `max_matches` option to set the number of enrich documents
+an incoming document can match. If set to the default of `1`, data is added to
+an incoming document's target field as a JSON object. Otherwise, the data is
+added as an array.
+
+See <<enrich-processor>> for a full list of configuration options.
+
+You also can add other <<ingest-processors,processors>> to your ingest pipeline.
+
+[[ingest-enrich-docs]]
+==== Ingest and enrich documents
+
+You can now use your ingest pipeline to enrich and index documents.
+
+image::images/ingest/enrich/enrich-process.svg[align="center"]
+
+Before implementing the pipeline in production, we recommend indexing a few test
+documents first and verifying enrich data was added correctly using the
+<<docs-get,get API>>.
+
+[[update-enrich-data]]
+==== Update an enrich index
+
+include::{docdir}/ingest/apis/enrich/execute-enrich-policy.asciidoc[tag=update-enrich-index]
+
+If wanted, you can <<docs-reindex,reindex>>
+or <<docs-update-by-query,update>> any already ingested documents
+using your ingest pipeline.
+
+[[update-enrich-policies]]
+==== Update an enrich policy
+
+include::apis/enrich/put-enrich-policy.asciidoc[tag=update-enrich-policy]
+
+[role="xpack"]
+[testenv="basic"]
+[[enrich-policy-definition]]
+=== Enrich policy definition
+
+<<enrich-policy,Enrich policies>> are defined as JSON objects like the
+following:
+
+[source,js]
+----
+{
+    "<enrich_policy_type>": {
+        "indices": ["..."],
+        "match_field": "...",
+        "enrich_fields": ["..."],
+        "query": "..."
+    }
+  }
+}
+----
+// NOTCONSOLE
+
+[[enrich-policy-parms]]
+==== Parameters
+
+`<enrich_policy_type>`::
++
+--
+(Required, enrich policy object)
+The enrich policy type determines how enrich data is matched to incoming
+documents.
+
+Supported enrich policy types include:
+
+<<geo-match-enrich-policy-type,`geo_match`>>:::
+Matches enrich data to incoming documents based on a geographic location using
+a <<query-dsl-geo-shape-query,`geo_shape` query>>. For an example, see
+<<geo-match-enrich-policy-type>>.
+
+<<match-enrich-policy-type,`match`>>:::
+Matches enrich data to incoming documents based on a precise value, such as an
+email address or ID, using a <<query-dsl-term-query,`term` query>>. For an
+example, see <<match-enrich-policy-type>>.
+--
+
+`indices`::
++
+--
+(Required, String or array of strings)
+Source indices used to create the enrich index.
+
+If multiple indices are provided, they must share a common `match_field`, which
+the enrich processor can use to match incoming documents.
+--
+
+`match_field`::
+(Required, string)
+Field in the source indices used to match incoming documents.
+
+`enrich_fields`::
+(Required, Array of strings)
+Fields to add to matching incoming documents. These fields must be present in
+the source indices.
+
+`query`::
+(Optional, string)
+Query type used to filter documents in the enrich index for matching. Valid
+value is <<query-dsl-match-all-query,`match_all`>> (default).
+
+[role="xpack"]
+[testenv="basic"]
+[[geo-match-enrich-policy-type]]
+=== Example: Enrich your data based on geolocation
+
+`geo_match` <<enrich-policy,enrich policies>> match enrich data to incoming
+documents based on a geographic location, using a
+<<query-dsl-geo-shape-query,`geo_shape` query>>.
+
+The following example creates a `geo_match` enrich policy that adds postal
+codes to incoming documents based on a set of coordinates. It then adds the
+`geo_match` enrich policy to a processor in an ingest pipeline.
+
+Use the <<indices-create-index,create index API>> to create a source index
+containing at least one `geo_shape` field.
+
+[source,console]
+----
+PUT /postal_codes
+{
+    "mappings": {
+        "properties": {
+            "location": {
+                "type": "geo_shape"
+            },
+            "postal_code": {
+                "type": "keyword"
+            } 
+        }
+    }
+}
+----
+
+Use the <<docs-index_,index API>> to index enrich data to this source index.
+
+[source,console]
+----
+PUT /postal_codes/_doc/1?refresh=wait_for
+{
+    "location": {
+        "type": "envelope",
+        "coordinates": [[13.0, 53.0], [14.0, 52.0]]
+    },
+    "postal_code": "96598"
+}
+----
+// TEST[continued]
+
+Use the <<put-enrich-policy-api,put enrich policy API>> to create an enrich
+policy with the `geo_match` policy type. This policy must include:
+
+* One or more source indices
+* A `match_field`,
+  the `geo_shape` field from the source indices used to match incoming documents
+* Enrich fields from the source indices you'd like to append to incoming
+  documents
+
+[source,console]
+----
+PUT /_enrich/policy/postal_policy
+{
+    "geo_match": {
+        "indices": "postal_codes",
+        "match_field": "location",
+        "enrich_fields": ["location","postal_code"]
+    }
+}
+----
+// TEST[continued]
+
+Use the <<execute-enrich-policy-api,execute enrich policy API>> to create an
+enrich index for the policy.
+
+[source,console]
+----
+POST /_enrich/policy/postal_policy/_execute
+----
+// TEST[continued]
+
+Use the <<put-pipeline-api,put pipeline API>> to create an ingest pipeline. In
+the pipeline, add an <<enrich-processor,enrich processor>> that includes:
+
+* Your enrich policy.
+* The `field` of incoming documents used to match the geo_shape of documents
+  from the enrich index.
+* The `target_field` used to store appended enrich data for incoming documents.
+* The `shape_relation`, which indicates how the processor matches geo_shapes in
+  incoming documents to geo_shapes in documents from the enrich index. See
+  <<_spatial_relations>> for valid options and more information.
+
+[source,console]
+----
+PUT /_ingest/pipeline/postal_lookup
+{
+  "description": "Enrich postal codes",
+  "processors": [
+    {
+      "enrich": {
+        "policy_name": "postal_policy",
+        "field": "geo_location",
+        "target_field": "geo_data",
+        "shape_relation": "INTERSECTS"
+      }
+    }
+  ]
+}
+----
+// TEST[continued]
 
-To begin,
-create one or more source indices.
+Use the ingest pipeline to index a document. The incoming document should
+include the `field` specified in your enrich processor.
 
-A _source index_ contains data you want to append to incoming documents.
-You can index and manage documents in a source index
-like a regular index.
+[source,console]
+----
+PUT /users/_doc/0?pipeline=postal_lookup
+{
+    "first_name": "Mardy",
+    "last_name": "Brown",
+    "geo_location": "POINT (13.5 52.5)"
+}
+----
+// TEST[continued]
 
-The following <<docs-index_,index API>> request creates the `users` source index
-containing user data.
-This request also indexes a new document to the `users` source index.
+To verify the enrich processor matched and appended the appropriate field data,
+use the <<docs-get,get API>> to view the indexed document.
+
+[source,console]
+----
+GET /users/_doc/0
+----
+// TEST[continued]
+
+The API returns the following response:
+
+[source,console-result]
+----
+{
+  "found": true,
+  "_index": "users",
+  "_id": "0",
+  "_version": 1,
+  "_seq_no": 55,
+  "_primary_term": 1,
+  "_source": {
+    "geo_data": {
+      "location": {
+        "type": "envelope",
+        "coordinates": [[13.0, 53.0], [14.0, 52.0]]
+      },
+      "postal_code": "96598"
+    },
+    "first_name": "Mardy",
+    "last_name": "Brown",
+    "geo_location": "POINT (13.5 52.5)"
+  }
+}
+----
+// TESTRESPONSE[s/"_seq_no": \d+/"_seq_no" : $body._seq_no/ s/"_primary_term":1/"_primary_term" : $body._primary_term/]
+
+////
+[source,console]
+--------------------------------------------------
+DELETE /_ingest/pipeline/postal_lookup
+DELETE /_enrich/policy/postal_policy
+--------------------------------------------------
+// TEST[continued]
+////
+
+[role="xpack"]
+[testenv="basic"]
+[[match-enrich-policy-type]]
+=== Example: Enrich your data based on exact values
+
+`match` <<enrich-policy,enrich policies>> match enrich data to incoming
+documents based on an exact value, such as a email address or ID, using a
+<<query-dsl-term-query,`term` query>>.
+
+The following example creates a `match` enrich policy that adds user name and
+contact information to incoming documents based on an email address. It then
+adds the `match` enrich policy to a processor in an ingest pipeline.
+
+Use the <<indices-create-index, create index API>> or <<docs-index_,index
+API>> to create a source index.
+
+The following index API request creates a source index and indexes a
+new document to that index.
 
 [source,console]
 ----
@@ -83,21 +487,14 @@ PUT /users/_doc/1?refresh=wait_for
 }
 ----
 
-You also can set up {beats-ref}/getting-started.html[{beats}],
-such as a {filebeat-ref}/filebeat-getting-started.html[{filebeat}],
-to automatically send and index documents
-to your source indices.
-See {beats-ref}/getting-started.html[Getting started with {beats}].
-
-
-[float]
-[[create-enrich-policy]]
-==== Create an enrich policy
+Use the put enrich policy API to create an enrich policy with the `match`
+policy type. This policy must include:
 
-Use the <<put-enrich-policy-api,put enrich policy API>>
-to create an enrich policy.
-
-include::{docdir}/ingest/apis/enrich/put-enrich-policy.asciidoc[tag=enrich-policy-def]
+* One or more source indices
+* A `match_field`,
+  the field from the source indices used to match incoming documents
+* Enrich fields from the source indices you'd like to append to incoming
+  documents
 
 [source,console]
 ----
@@ -112,19 +509,8 @@ PUT /_enrich/policy/users-policy
 ----
 // TEST[continued]
 
-
-[float]
-[[execute-enrich-policy]]
-==== Execute an enrich policy
-
-Use the <<execute-enrich-policy-api,execute enrich policy API>>
-to create an enrich index for the policy.
-
-include::apis/enrich/execute-enrich-policy.asciidoc[tag=execute-enrich-policy-def]
-
-The following request executes the `users-policy` enrich policy.
-Because this API request performs several operations,
-it may take a while to return a response.
+Use the <<execute-enrich-policy-api,execute enrich policy API>> to create an
+enrich index for the policy.
 
 [source,console]
 ----
@@ -133,29 +519,13 @@ POST /_enrich/policy/users-policy/_execute
 // TEST[continued]
 
 
-[float]
-[[add-enrich-processor]]
-==== Add the enrich processor to an ingest pipeline
-
-Use the <<put-pipeline-api,put pipeline API>>
-to create an ingest pipeline.
-Include an <<enrich-processor,enrich processor>>
-that uses your enrich policy.
-
-When defining an enrich processor,
-you must include the following:
-
-* The field used to match incoming documents
-  to documents in the enrich index.
-+
-This field should be included in incoming documents.
-
-* The target field added to incoming documents.
-  This field contains all appended enrich data.
+Use the <<put-pipeline-api,put pipeline API>> to create an ingest pipeline. In
+the pipeline, add an <<enrich-processor,enrich processor>> that includes:
 
-The following request adds a new pipeline, `user_lookup`.
-This pipeline includes an enrich processor
-that uses the `users-policy` enrich policy.
+* Your enrich policy.
+* The `field` of incoming documents used to match documents
+  from the enrich index.
+* The `target_field` used to store appended enrich data for incoming documents.
 
 [source,console]
 ----
@@ -176,42 +546,8 @@ PUT /_ingest/pipeline/user_lookup
 ----
 // TEST[continued]
 
-Because the enrich policy type is `match`,
-the enrich processor matches incoming documents
-to documents in the enrich index
-based on match field values.
-The enrich processor then appends the enrich field data 
-from matching documents in the enrich index
-to the target field of incoming documents.
-
-Because the `max_matches` option for the enrich processor is `1`,
-the enrich processor appends the data from only the best matching document
-to each incoming document's target field as an object.
-
-If the `max_matches` option were greater than `1`,
-the processor could append data from up to the `max_matches` number of documents
-to the target field as an array.
-
-If the incoming document matches no documents in the enrich index,
-the processor appends no data.
-
-You also can add other <<ingest-processors,processors>>
-to your ingest pipeline.
-You can use these processors to change or drop incoming documents
-based on your criteria.
-See <<ingest-processors>> for a list of built-in processors.
-
-
-[float]
-[[ingest-enrich-docs]]
-==== Ingest and enrich documents
-
-Index incoming documents using your ingest pipeline.
-
-The following <<docs-index_,index API>> request uses the ingest pipeline
-to index a document
-containing the `email` field
-specified in the enrich processor.
+Use the ingest pipeline to index a document. The incoming document should
+include the `field` specified in your enrich processor.
 
 [source,console]
 ----
@@ -222,8 +558,7 @@ PUT /my_index/_doc/my_id?pipeline=user_lookup
 ----
 // TEST[continued]
 
-To verify the enrich processor matched 
-and appended the appropriate field data,
+To verify the enrich processor matched and appended the appropriate field data,
 use the <<docs-get,get API>> to view the indexed document.
 
 [source,console]
@@ -257,31 +592,3 @@ The API returns the following response:
 }
 ----
 // TESTRESPONSE[s/"_seq_no": \d+/"_seq_no" : $body._seq_no/ s/"_primary_term":1/"_primary_term" : $body._primary_term/]
-
-
-[float]
-[[update-enrich-data]]
-=== Update your enrich index
-
-include::{docdir}/ingest/apis/enrich/execute-enrich-policy.asciidoc[tag=update-enrich-index]
-
-If wanted, you can <<docs-reindex,reindex>>
-or <<docs-update-by-query,update>> any already ingested documents
-using your ingest pipeline.
-
-
-[float]
-[[update-enrich-policies]]
-=== Update an enrich policy
-
-include::apis/enrich/put-enrich-policy.asciidoc[tag=update-enrich-policy]
-
-////
-[source,console]
---------------------------------------------------
-DELETE /_ingest/pipeline/user_lookup
-
-DELETE /_enrich/policy/users-policy
---------------------------------------------------
-// TEST[continued]
-////

Some files were not shown because too many files changed in this diff