elasticsearch/docs/reference/esql/processing-commands/lookup.asciidoc
Nik Everett 1256a49c3a
ESQL: Move description of commands in docs (#110714)
This copies the first line of the description of each command to just
under the syntax so that it's "in order", before the `Parameters`
section. That way if you are reading from top to bottom you see:
```
syntax
short description
parameter names and descriptions
long description
examples
```

I've also removed the `Description` section entirely if the description
was just one sentence. So in some cases that just isn't `long
description`.
2024-07-11 08:31:35 -04:00

63 lines
1.5 KiB
Text

[discrete]
[[esql-lookup]]
=== `LOOKUP`
experimental::["LOOKUP is a highly experimental and only available in SNAPSHOT versions."]
`LOOKUP` matches values from the input against a `table` provided in the request,
adding the other fields from the `table` to the output.
**Syntax**
[source,esql]
----
LOOKUP table ON match_field1[, match_field2, ...]
----
*Parameters*
`table`::
The name of the `table` provided in the request to match.
`match_field`::
The fields in the input to match against the table.
*Examples*
// tag::examples[]
[source,console,id=esql-lookup-example]
----
POST /_query?format=txt
{
"query": """
FROM library
| SORT page_count DESC
| KEEP name, author
| LOOKUP era ON author
| LIMIT 5
""",
"tables": {
"era": {
"author": {"keyword": ["Frank Herbert", "Peter F. Hamilton", "Vernor Vinge", "Alastair Reynolds", "James S.A. Corey"]},
"era": {"keyword": [ "The New Wave", "Diamond", "Diamond", "Diamond", "Hadron"]}
}
}
}
----
// TEST[setup:library]
Which returns:
[source,text]
----
name | author | era
--------------------+-----------------+---------------
Pandora's Star |Peter F. Hamilton|Diamond
A Fire Upon the Deep|Vernor Vinge |Diamond
Dune |Frank Herbert |The New Wave
Revelation Space |Alastair Reynolds|Diamond
Leviathan Wakes |James S.A. Corey |Hadron
----
// TESTRESPONSE[s/\|/\\|/ s/\+/\\+/]
// TESTRESPONSE[non_json]
// end::examples[]