Skip to content

Commit 9725f7a

Browse files
committed
[8.x] ESQL: Add more details on ENRICH vs. LOOKUP JOIN elastic#125487 (elastic#125528)
Manual backport of docs-PR elastic#125487
1 parent f7d6a78 commit 9725f7a

File tree

3 files changed

+25
-26
lines changed

3 files changed

+25
-26
lines changed

docs/reference/esql/esql-enrich-data.asciidoc

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,10 +19,10 @@ For example, you can use `ENRICH` to:
1919

2020
* Enrichment data doesn't change frequently
2121
* You can accept index-time overhead
22-
* You are working with structured enrichment patterns
2322
* You can accept having multiple matches combined into multi-values
2423
* You can accept being limited to predefined match fields
25-
* `ENRICH` has a simplified security model. There are no restrictions to specific enrich policies or document and field level security.
24+
* You do not need fine-grained security: There are no restrictions to specific enrich policies or document and field level security.
25+
* You want to match using ranges or spatial relations
2626

2727
[discrete]
2828
[[esql-how-enrich-works]]

docs/reference/esql/esql-lookup-join.asciidoc

Lines changed: 9 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
<titleabbrev>Correlate data with LOOKUP JOIN</titleabbrev>
55
++++
66

7-
The {esql} <<esql-lookup-join,LOOKUP join>>
7+
The {esql} <<esql-lookup-join,LOOKUP join>>
88
processing command combines data from your {esql} query results
99
table with matching records from a specified lookup index. It adds
1010
fields from the lookup index as new columns to your results table based
@@ -29,12 +29,11 @@ in the fact that they both help you join data together. You should use
2929

3030
* Your enrichment data changes frequently
3131
* You want to avoid index-time processing
32-
* You're working with regular indices
33-
* You need to preserve distinct matches
32+
* You want SQL-like behavior, so that multiple matches result in multiple rows
3433
* You need to match on any field in a lookup index
3534
* You use document or field level security
36-
* You want to restrict users to a specific lookup indices that they can
37-
you
35+
* You want to restrict users to use only specific lookup indices
36+
* You do not need to match using ranges or spatial relations
3837
3938
[discrete]
4039
[[esql-how-lookup-join-works]]
@@ -146,7 +145,7 @@ To use `LOOKUP JOIN`, the following requirements must be met:
146145
* *Compatible data types*: The join key and join field in the lookup
147146
index must have compatible data types. This means:
148147
** The data types must either be identical or be internally represented
149-
as the same type in Elasticsearch's type system
148+
as the same type in {esql}
150149
** Numeric types follow these compatibility rules:
151150
*** `short` and `byte` are compatible with `integer` (all represented as
152151
`int`)
@@ -164,18 +163,15 @@ representations, see the <<esql-supported-types,Supported Field Types documentat
164163

165164
The following are the current limitations with `LOOKUP JOIN`
166165

167-
* `LOOKUP JOIN` will be successful if the join field in the lookup index
168-
is a `KEYWORD` type. If the main index's join field is `TEXT` type, it
169-
must have an exact `.keyword` subfield that can be matched with the
170-
lookup index's `KEYWORD` field.
171166
* Indices in <<index-mode-setting,lookup>> mode are always single-sharded.
172167
* Cross cluster search is unsupported. Both source and lookup indices
173168
must be local.
169+
* Currently, only matching on equality is supported.
174170
* `LOOKUP JOIN` can only use a single match field and a single index.
175171
Wildcards, aliases, datemath, and datastreams are not supported.
176-
* The name of the match field in
177-
`LOOKUP JOIN lu++_++idx ON match++_++field` must match an existing field
178-
in the query. This may require renames or evals to achieve.
172+
* The name of the match field in `LOOKUP JOIN lu_idx ON match_field` must match
173+
an existing field in the query. This may require `RENAME`s or `EVAL`s to
174+
achieve.
179175
* The query will circuit break if there are too many matching documents
180176
in the lookup index, or if the documents are too large. More precisely,
181177
`LOOKUP JOIN` works in batches of, normally, about 10,000 rows; a large

docs/reference/esql/processing-commands/lookup.asciidoc

Lines changed: 14 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
=== `LOOKUP JOIN`
44

55
[WARNING]
6-
====
6+
====
77
This functionality is in technical preview and may be
88
changed or removed in a future release. Elastic will work to fix any
99
issues, but features in technical preview are not subject to the support
@@ -15,16 +15,10 @@ and analysis workflows.
1515

1616
*Syntax*
1717

18-
....
19-
FROM <source_index>
20-
| LOOKUP JOIN <lookup_index> ON <field_name>
21-
....
22-
2318
[source,esql]
2419
----
25-
FROM firewall_logs
26-
| LOOKUP JOIN threat_list ON source.IP
27-
| WHERE threat_level IS NOT NULL
20+
FROM <source_index>
21+
| LOOKUP JOIN <lookup_index> ON <field_name>
2822
----
2923

3024
*Parameters*
@@ -33,7 +27,7 @@ FROM firewall_logs
3327
The name of the lookup index. This must be a specific index name - wildcards, aliases, and remote cluster
3428
references are not supported.
3529

36-
`field_name`::
30+
`field_name`::
3731
The field to join on. This field must exist
3832
in both your current query results and in the lookup index. If the field
3933
contains multi-valued entries, those entries will not match anything
@@ -68,6 +62,15 @@ FROM firewall_logs
6862
| LOOKUP JOIN threat_list ON source.IP
6963
----
7064

65+
To filter only for those rows that have a matching `threat_list` entry, use `WHERE ... IS NOT NULL` with a field from the lookup index:
66+
67+
[source,esql]
68+
----
69+
FROM firewall_logs
70+
| LOOKUP JOIN threat_list ON source.IP
71+
| WHERE threat_level IS NOT NULL
72+
----
73+
7174
*Host metadata correlation*: This query pulls in environment or
7275
ownership details for each host to correlate with your metrics data.
7376

@@ -107,5 +110,5 @@ FROM Left
107110
----
108111
FROM Left
109112
| LOOKUP JOIN Right ON Key
110-
| WHERE Language IS NOT NULL
113+
| WHERE Language IS NOT NULL
111114
----

0 commit comments

Comments
 (0)