You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: docs/reference/query-languages/esql/esql-lookup-join.md
+42-1Lines changed: 42 additions & 1 deletion
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -24,12 +24,53 @@ For example, you can use `LOOKUP JOIN` to:
24
24
25
25
## How the `LOOKUP JOIN` command works [esql-how-lookup-join-works]
26
26
27
-
The `LOOKUP JOIN` command adds new columns to a table, with data from {{es}} indices. It requires a few special components:
27
+
The `LOOKUP JOIN` command adds new columns to a table, with data from {{es}} indices.
28
28
29
29
:::{image} ../../../images/esql-lookup-join.png
30
30
:alt: esql lookup join
31
31
:::
32
32
33
+
In the case where there are multiple matches on the index `LOOKUP JOIN` the output rows is the combination of each match from the left with each match on the right.
34
+
35
+
Image you have the two tables:
36
+
37
+
**Left**
38
+
39
+
|Key|Entry|
40
+
| --- | --- |
41
+
|1|A|
42
+
|2|B|
43
+
44
+
**Right**
45
+
46
+
|Key|Language|TLD|
47
+
|---|---|---|
48
+
|1|English|CA|
49
+
|1|English|null|
50
+
|1|null|UK|
51
+
|1|English|US|
52
+
|2|German|AT,DE|
53
+
|2|German|CH|
54
+
|2|German|null|
55
+
56
+
Running the following query would provide the results shown below.
57
+
58
+
```esql
59
+
FROM Left
60
+
| WHERE Language IS NOT NULL // works and filter TLD UK
61
+
| LOOKUP JOIN Right ON Key
62
+
```
63
+
64
+
|Key|Entry|Language|TLD|
65
+
|---|---|---|---|
66
+
|1|A|English|CA|
67
+
|1|A|English|null|
68
+
|1|A|null|UK|
69
+
|1|A|English|US|
70
+
|2|A|German|AT,DE|
71
+
|2|B|German|CH|
72
+
|2|B|German|null|
73
+
33
74
::::{tip}
34
75
`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`.
0 commit comments