Skip to content

Commit 1714289

Browse files
committed
providing example
1 parent 13b73a6 commit 1714289

File tree

1 file changed

+42
-1
lines changed

1 file changed

+42
-1
lines changed

docs/reference/query-languages/esql/esql-lookup-join.md

Lines changed: 42 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,12 +24,53 @@ For example, you can use `LOOKUP JOIN` to:
2424

2525
## How the `LOOKUP JOIN` command works [esql-how-lookup-join-works]
2626

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.
2828

2929
:::{image} ../../../images/esql-lookup-join.png
3030
:alt: esql lookup join
3131
:::
3232

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+
3374
::::{tip}
3475
`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`.
3576

0 commit comments

Comments
 (0)