|
1 | 1 | --- |
2 | | -navigation_title: "LOOKUP JOIN" |
| 2 | +navigation_title: "Correlate data with LOOKUP JOIN" |
3 | 3 | mapped_pages: |
4 | 4 | - https://www.elastic.co/guide/en/elasticsearch/reference/current/esql-enrich-data.html |
5 | 5 | --- |
6 | 6 |
|
7 | 7 | # LOOKUP JOIN [esql-lookup-join] |
8 | 8 |
|
9 | | -The {{esql}} [`LOOKUP join`](/reference/query-languages/esql/esql-commands.md#esql-lookup-join) processing command combines, at query-time, data from one or more source indexes with field-value combinations found in an input table. |
| 9 | +The {{esql}} [`LOOKUP join`](/reference/query-languages/esql/esql-commands.md#esql-lookup-join) processing command combines, at query-time, data from one or more source indexes with field-value combinations found in an input table. Teams often have data scattered across multiple indices – like logs, IPs, user IDs, hosts, employees etc. Without a direct way to enrich or correlate each event with reference data, root-cause analysis, security checks, and operational insights become time-consuming. |
10 | 10 |
|
11 | 11 | For example, you can use `LOOKUP JOIN` to: |
12 | 12 |
|
13 | | -* Pull in environment or ownership details for each host to enrich your metrics data |
| 13 | +* Pull in environment or ownership details for each host to correlate your metrics data. |
14 | 14 | * Quickly see if any source IPs match known malicious addresses. |
15 | 15 | * Tag logs with the owning team or escalation info for faster triage and incident response. |
16 | 16 |
|
| 17 | +[`LOOKUP join`](/reference/query-languages/esql/esql-commands.md#esql-lookup-join) is similar to [`ENRICH`](/reference/query-languages/esql/esql-commands.md#esql-enrich) in the fact that they both help you join data together. You should use `LOOKUP JOIN` when: |
17 | 18 |
|
18 | | -### How the `LOOKUP JOIN` command works [esql-how-lookup-join-works] |
| 19 | +* Enrichment data changes frequently |
| 20 | +* You want to avoid index time processing |
| 21 | +* Working with regular indices |
| 22 | +* Need to preserve distinct matches |
| 23 | +* Need to match on any field in a lookup index |
| 24 | + |
| 25 | +## How the `LOOKUP JOIN` command works [esql-how-lookup-join-works] |
19 | 26 |
|
20 | 27 | The `LOOKUP JOIN` command adds new columns to a table, with data from {{es}} indices. It requires a few special components: |
21 | 28 |
|
22 | 29 | :::{image} ../../../images/esql-lookup-join.png |
23 | 30 | :alt: esql lookup join |
24 | 31 | ::: |
25 | 32 |
|
| 33 | +::::{tip} |
| 34 | +`LOOKUP JOIN` does not guarantee the output to be in any particular order. If a certain order is required, users should use a [`SORT`](/reference/query-languages/esql/esql-commands.md#esql-sort) somewhere after the `LOOKUP JOIN`. |
| 35 | + |
| 36 | +:::: |
26 | 37 |
|
27 | 38 | $$$esql-source-index$$$ |
28 | 39 |
|
29 | 40 | Source index |
30 | 41 | : An index which stores enrich data that the `LOOKUP` command can add to input tables. 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. |
31 | 42 |
|
32 | 43 |
|
33 | | -### Prerequisites [esql-enrich-prereqs] |
| 44 | +## Prerequisites [esql-enrich-prereqs] |
34 | 45 |
|
35 | 46 | To use `LOOKUP JOIN`, you must have: |
36 | 47 |
|
37 | 48 | * Data types of join key and join field in the lookup index need to generally be the same - up to widening of data types, where e.g. `short,byte` are considered equal to `integer`. Also, text fields can be used on the left hand side if and only if there is an exact subfield whose name is suffixed with `.keyword`. |
38 | 49 |
|
| 50 | +## Limitations |
| 51 | + |
| 52 | +The following is a list of current limitations with `LOOKUP JOIN` |
| 53 | + |
| 54 | +* `LOOKUP JOIN` will be sucessfull if both left and right type of the join are both `KEYWORD` types or if the left type is of `TEXT` and the right type is `KEYWORD`. |
| 55 | +* Indices in [lookup](elasticsearch/docs/reference/elasticsearch/index-settings/index-modules.md#index-mode-setting) mode are always single-sharded. |
| 56 | +* Cross cluster search is unsupported. Both source and lookup indicies must be local. |
| 57 | +* `LOOKUP JOIN` can only use a single match field, and can only use a single index. Wildcards, aliases, and datastreams are not supported. |
| 58 | +* The name of the match field in `LOOKUP JOIN lu_idx ON match_field` must match an existing field in the query. This may require renames or evals to achieve it. |
| 59 | +* The query will circuit break if you fetch too much data in a single page. A large heap is needed to manage results of multiple megabytes. |
| 60 | + * This limit is per page of data which is about about 10,000 rows. |
| 61 | + * Matching many rows per incoming row will count against this limit. |
| 62 | + * This limit is approximately the same as for [`ENRICH`](/reference/query-languages/esql/esql-commands.md#esql-enrich). |
| 63 | + |
0 commit comments