Skip to content

Commit

Permalink
Ensure nested field could be used in lookup joins (elastic#118963)
Browse files Browse the repository at this point in the history
  • Loading branch information
idegtiarenko committed Dec 19, 2024
1 parent 2ae5911 commit 712186e
Show file tree
Hide file tree
Showing 4 changed files with 82 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,11 @@ public class CsvTestsDataLoader {
.withSetting("languages_lookup-settings.json");
private static final TestsDataset LANGUAGES_LOOKUP_NON_UNIQUE_KEY = LANGUAGES_LOOKUP.withIndex("languages_lookup_non_unique_key")
.withData("languages_non_unique_key.csv");
private static final TestsDataset LANGUAGES_NESTED_FIELDS = new TestsDataset(
"languages_nested_fields",
"mapping-languages_nested_fields.json",
"languages_nested_fields.csv"
).withSetting("languages_lookup-settings.json");
private static final TestsDataset ALERTS = new TestsDataset("alerts");
private static final TestsDataset UL_LOGS = new TestsDataset("ul_logs");
private static final TestsDataset SAMPLE_DATA = new TestsDataset("sample_data");
Expand Down Expand Up @@ -116,6 +121,7 @@ public class CsvTestsDataLoader {
Map.entry(LANGUAGES.indexName, LANGUAGES),
Map.entry(LANGUAGES_LOOKUP.indexName, LANGUAGES_LOOKUP),
Map.entry(LANGUAGES_LOOKUP_NON_UNIQUE_KEY.indexName, LANGUAGES_LOOKUP_NON_UNIQUE_KEY),
Map.entry(LANGUAGES_NESTED_FIELDS.indexName, LANGUAGES_NESTED_FIELDS),
Map.entry(UL_LOGS.indexName, UL_LOGS),
Map.entry(SAMPLE_DATA.indexName, SAMPLE_DATA),
Map.entry(MV_SAMPLE_DATA.indexName, MV_SAMPLE_DATA),
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
_id:integer,language.id:integer,language.name:text,language.code:keyword
1,1,English,EN
2,2,French,FR
3,3,Spanish,ES
4,4,German,DE
Original file line number Diff line number Diff line change
Expand Up @@ -416,6 +416,55 @@ language_code:integer | language_name:keyword | country:keyword
8 | Mv-Lang2 | Mv-Land2
;

###########################################################################
# nested filed join behavior with languages_nested_fields index
###########################################################################

joinOnNestedField
required_capability: join_lookup_v8

FROM employees
| WHERE 10000 < emp_no AND emp_no < 10006
| EVAL language.id = emp_no % 10
| LOOKUP JOIN languages_nested_fields ON language.id
| SORT emp_no
| KEEP emp_no, language.id, language.name
;

emp_no:integer | language.id:integer | language.name:text
10001 | 1 | English
10002 | 2 | French
10003 | 3 | Spanish
10004 | 4 | German
10005 | 5 | null
;


joinOnNestedFieldRow
required_capability: join_lookup_v8

ROW language.code = "EN"
| LOOKUP JOIN languages_nested_fields ON language.code
| KEEP language.id, language.code, language.name.keyword
;

language.id:integer | language.code:keyword | language.name.keyword:keyword
1 | EN | English
;


joinOnNestedNestedFieldRow
required_capability: join_lookup_v8

ROW language.name.keyword = "English"
| LOOKUP JOIN languages_nested_fields ON language.name.keyword
| KEEP language.id, language.name, language.name.keyword
;

language.id:integer | language.name:text | language.name.keyword:keyword
1 | English | English
;

###############################################
# Tests with clientips_lookup index
###############################################
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
{
"properties" : {
"language" : {
"properties" : {
"id": {
"type": "integer"
},
"name": {
"type": "text",
"fields": {
"keyword": {
"type": "keyword"
}
}
},
"code": {
"type": "keyword"
}
}
}
}
}

0 comments on commit 712186e

Please sign in to comment.