Skip to content

Commit 724d3d4

Browse files
committed
Code review suggestions
1 parent 8e554e9 commit 724d3d4

File tree

3 files changed

+29
-12
lines changed

3 files changed

+29
-12
lines changed

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

Lines changed: 26 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -142,24 +142,38 @@ Refer to the examples section of the [`LOOKUP JOIN`](/reference/query-languages/
142142

143143
## Prerequisites [esql-lookup-join-prereqs]
144144

145-
To use `LOOKUP JOIN`, the following requirements must be met:
145+
### Index configuration
146146

147-
* Indices used for lookups must be configured with the [`lookup` index mode](/reference/elasticsearch/index-settings/index-modules.md#index-mode-setting)
148-
* **Compatible data types**: The join key and join field in the lookup index must have compatible data types. This means:
149-
* The data types must either be identical or be internally represented as the same type in {{esql}}
150-
* Numeric types follow these compatibility rules:
151-
* `short` and `byte` are compatible with `integer` (all represented as `int`)
152-
* `float`, `half_float`, and `scaled_float` are compatible with `double` (all represented as `double`)
153-
* For text fields: You can only use text fields as the join key on the left-hand side of the join and only if they have a `.keyword` subfield
154-
* `DATE` and `DATE_NANOS` can only be joined against the exact same type.
147+
Indices used for lookups must be configured with the [`lookup` index mode](/reference/elasticsearch/index-settings/index-modules.md#index-mode-setting).
155148

149+
### Data type compatibility
150+
151+
Join keys must have compatible data types between the source and lookup indices. Types within the same compatibility group can be joined together:
152+
153+
| Compatibility group | Types | Notes |
154+
|------------------------|-------------------------------------------------------------------------------------|----------------------------------------------------------------------------------|
155+
| **Numeric family** | `byte`, `short`, `integer`, `long`, `half_float`, `float`, `scaled_float`, `double` | All compatible |
156+
| **Keyword family** | `keyword`, `text.keyword` | Text fields only as join key on left-hand side and must have `.keyword` subfield |
157+
| **Date (Exact)** | `date` | Must match exactly |
158+
| **Date Nanos (Exact)** | `date_nanos` | Must match exactly |
159+
| **Boolean** | `boolean` | Must match exactly |
160+
161+
```{tip}
156162
To obtain a join key with a compatible type, use a [conversion function](/reference/query-languages/esql/functions-operators/type-conversion-functions.md) if needed.
163+
```
157164

158-
The list of unsupported fields includes all types not supported by {{esql}} as described in the [Unsupported Field Types documentation](/reference/query-languages/esql/limitations.md#_unsupported_types).
159-
as well as the following: `VERSION`, `UNSIGNED_LONG`, all spatial types like `GEO_POINT`, `GEO_SHAPE`, and all
160-
temporal periods like `DURATION` and `PERIOD`.
165+
### Unsupported Types
161166

167+
In addition to the [{{esql}} unsupported field types](/reference/query-languages/esql/limitations.md#_unsupported_types), `LOOKUP JOIN` does not support:
168+
169+
* `VERSION`
170+
* `UNSIGNED_LONG`
171+
* Spatial types like `GEO_POINT`, `GEO_SHAPE`
172+
* Temporal intervals like `DURATION`, `PERIOD`
173+
174+
```{note}
162175
For a complete list of all types supported in `LOOKUP JOIN`, refer to the [`LOOKUP JOIN` supported types table](/reference/query-languages/esql/commands/processing-commands.md#esql-lookup-join).
176+
```
163177

164178
## Usage notes
165179

x-pack/plugin/esql/build.gradle

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -226,6 +226,8 @@ tasks.named("test").configure {
226226
}
227227
}
228228

229+
// This is similar to the test task above, but needed for the LookupJoinTypesIT which runs in the internalClusterTest task
230+
// and generates a types table for the LOOKUP JOIN command. It is possible in future we might have move tests that do this.
229231
tasks.named("internalClusterTest").configure {
230232
if (buildParams.ci == false) {
231233
systemProperty 'generateDocs', true

x-pack/plugin/esql/src/internalClusterTest/java/org/elasticsearch/xpack/esql/action/LookupJoinTypesIT.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -268,6 +268,7 @@ private static boolean existingIndex(Collection<TestConfigs> existing, DataType
268268
return existing.stream().anyMatch(c -> c.exists(indexName));
269269
}
270270

271+
/** This test generates documentation for the supported output types of the lookup join. */
271272
public void testOutputSupportedTypes() throws Exception {
272273
Map<List<DataType>, DataType> signatures = new LinkedHashMap<>();
273274
for (TestConfigs configs : testConfigurations.values()) {

0 commit comments

Comments
 (0)