|
|
@@ -6,7 +6,7 @@ setup:
|
|
|
features: allowed_warnings_regex
|
|
|
- do:
|
|
|
indices.create:
|
|
|
- index: cities
|
|
|
+ index: cities
|
|
|
body:
|
|
|
settings:
|
|
|
number_of_shards: 5
|
|
|
@@ -15,13 +15,13 @@ setup:
|
|
|
city_code:
|
|
|
type: keyword
|
|
|
city:
|
|
|
- type: keyword
|
|
|
+ type: text
|
|
|
country:
|
|
|
type: keyword
|
|
|
|
|
|
- do:
|
|
|
bulk:
|
|
|
- index: "cities"
|
|
|
+ index: cities
|
|
|
refresh: true
|
|
|
body:
|
|
|
- { "index": { } }
|
|
|
@@ -31,16 +31,29 @@ setup:
|
|
|
|
|
|
- do:
|
|
|
enrich.put_policy:
|
|
|
- name: cities_policy
|
|
|
+ name: city_codes_policy
|
|
|
body:
|
|
|
match:
|
|
|
- indices: ["cities"]
|
|
|
+ indices: [ "cities" ]
|
|
|
match_field: "city_code"
|
|
|
- enrich_fields: ["city", "country"]
|
|
|
+ enrich_fields: [ "city", "country" ]
|
|
|
+
|
|
|
+ - do:
|
|
|
+ enrich.put_policy:
|
|
|
+ name: city_names_policy
|
|
|
+ body:
|
|
|
+ match:
|
|
|
+ indices: [ "cities" ]
|
|
|
+ match_field: "city"
|
|
|
+ enrich_fields: [ "city_code", "country" ]
|
|
|
+
|
|
|
+ - do:
|
|
|
+ enrich.execute_policy:
|
|
|
+ name: city_codes_policy
|
|
|
|
|
|
- do:
|
|
|
enrich.execute_policy:
|
|
|
- name: cities_policy
|
|
|
+ name: city_names_policy
|
|
|
|
|
|
- do:
|
|
|
indices.create:
|
|
|
@@ -52,39 +65,44 @@ setup:
|
|
|
type: keyword
|
|
|
city_id:
|
|
|
type: keyword
|
|
|
+ city_name:
|
|
|
+ type: text
|
|
|
- do:
|
|
|
bulk:
|
|
|
- index: "test"
|
|
|
+ index: test
|
|
|
refresh: true
|
|
|
body:
|
|
|
- { "index": { } }
|
|
|
- - { "name": "Alice", "city_id": "nyc" }
|
|
|
+ - { "name": "Alice", "city_id": "nyc", "city_name": "New York" }
|
|
|
- { "index": { } }
|
|
|
- - { "name": "Bob", "city_id": "nyc" }
|
|
|
+ - { "name": "Bob", "city_id": "nyc", "city_name": "New York" }
|
|
|
- { "index": { } }
|
|
|
- - { "name": "Mario", "city_id": "rom" }
|
|
|
+ - { "name": "Mario", "city_id": "rom", "city_name": "Rome" }
|
|
|
- { "index": { } }
|
|
|
- - { "name": "Denise", "city_id": "sgn" }
|
|
|
+ - { "name": "Denise", "city_id": "sgn", "city_name": "Tan Son Nhat" }
|
|
|
|
|
|
---
|
|
|
teardown:
|
|
|
- do:
|
|
|
enrich.delete_policy:
|
|
|
- name: cities_policy
|
|
|
+ name: city_codes_policy
|
|
|
+ - do:
|
|
|
+ enrich.delete_policy:
|
|
|
+ name: city_names_policy
|
|
|
|
|
|
---
|
|
|
-"Basic":
|
|
|
+"Enrich on keyword":
|
|
|
- do:
|
|
|
allowed_warnings_regex:
|
|
|
- "No limit defined, adding default limit of \\[.*\\]"
|
|
|
esql.query:
|
|
|
body:
|
|
|
- query: 'from test | enrich cities_policy on city_id | keep name, city, country | sort name'
|
|
|
+ query: 'from test | enrich city_codes_policy on city_id | keep name, city, country | sort name'
|
|
|
|
|
|
- match: { columns.0.name: "name" }
|
|
|
- match: { columns.0.type: "keyword" }
|
|
|
- match: { columns.1.name: "city" }
|
|
|
- - match: { columns.1.type: "keyword" }
|
|
|
+ - match: { columns.1.type: "text" }
|
|
|
- match: { columns.2.name: "country" }
|
|
|
- match: { columns.2.type: "keyword" }
|
|
|
|
|
|
@@ -95,12 +113,14 @@ teardown:
|
|
|
- match: { values.3: [ "Mario", "Rome", "Italy" ] }
|
|
|
|
|
|
|
|
|
+---
|
|
|
+"Enrich on keyword with fields":
|
|
|
- do:
|
|
|
allowed_warnings_regex:
|
|
|
- "No limit defined, adding default limit of \\[.*\\]"
|
|
|
esql.query:
|
|
|
body:
|
|
|
- query: 'from test | keep name, city_id | enrich cities_policy on city_id with country | sort name'
|
|
|
+ query: 'from test | keep name, city_id | enrich city_codes_policy on city_id with country | sort name'
|
|
|
|
|
|
- match: { columns.0.name: "name" }
|
|
|
- match: { columns.0.type: "keyword" }
|
|
|
@@ -116,12 +136,14 @@ teardown:
|
|
|
- match: { values.3: [ "Mario", "rom", "Italy" ] }
|
|
|
|
|
|
|
|
|
+---
|
|
|
+"Enrich on keyword with fields alias":
|
|
|
- do:
|
|
|
allowed_warnings_regex:
|
|
|
- "No limit defined, adding default limit of \\[.*\\]"
|
|
|
esql.query:
|
|
|
body:
|
|
|
- query: 'from test | keep name, city_id | enrich cities_policy on city_id with country_name = country | sort name'
|
|
|
+ query: 'from test | keep name, city_id | enrich city_codes_policy on city_id with country_name = country | sort name'
|
|
|
|
|
|
- match: { columns.0.name: "name" }
|
|
|
- match: { columns.0.type: "keyword" }
|
|
|
@@ -135,3 +157,32 @@ teardown:
|
|
|
- match: { values.1: [ "Bob", "nyc", "USA" ] }
|
|
|
- match: { values.2: [ "Denise", "sgn", null ] }
|
|
|
- match: { values.3: [ "Mario", "rom", "Italy" ] }
|
|
|
+
|
|
|
+
|
|
|
+---
|
|
|
+"Enrich on text":
|
|
|
+ - skip:
|
|
|
+ version: " - 8.13.99"
|
|
|
+ reason: "TEXT field ENRICH support was added in 8.14.0"
|
|
|
+
|
|
|
+ - do:
|
|
|
+ allowed_warnings_regex:
|
|
|
+ - "No limit defined, adding default limit of \\[.*\\]"
|
|
|
+ esql.query:
|
|
|
+ body:
|
|
|
+ query: 'from test | keep name, city_name | enrich city_names_policy on city_name | sort name'
|
|
|
+
|
|
|
+ - match: { columns.0.name: "name" }
|
|
|
+ - match: { columns.0.type: "keyword" }
|
|
|
+ - match: { columns.1.name: "city_name" }
|
|
|
+ - match: { columns.1.type: "text" }
|
|
|
+ - match: { columns.2.name: "city_code" }
|
|
|
+ - match: { columns.2.type: "keyword" }
|
|
|
+ - match: { columns.3.name: "country" }
|
|
|
+ - match: { columns.3.type: "keyword" }
|
|
|
+
|
|
|
+ - length: { values: 4 }
|
|
|
+ - match: { values.0: [ "Alice", "New York", "nyc", "USA" ] }
|
|
|
+ - match: { values.1: [ "Bob", "New York", "nyc", "USA" ] }
|
|
|
+ - match: { values.2: [ "Denise", "Tan Son Nhat", null, null ] }
|
|
|
+ - match: { values.3: [ "Mario", "Rome", "rom", "Italy" ] }
|