From a40d251db47b57e88844019070a6d5804425df3b Mon Sep 17 00:00:00 2001 From: Sander Bouwhuis Date: Sun, 26 Aug 2018 10:40:44 +0200 Subject: [PATCH 1/3] Support named queries in elasticsearch response --- types/elasticsearch/index.d.ts | 1 + 1 file changed, 1 insertion(+) diff --git a/types/elasticsearch/index.d.ts b/types/elasticsearch/index.d.ts index c791db72c3..a9dc133545 100644 --- a/types/elasticsearch/index.d.ts +++ b/types/elasticsearch/index.d.ts @@ -645,6 +645,7 @@ export interface SearchResponse { fields?: any; highlight?: any; inner_hits?: any; + matched_queries?: string[]; sort?: string[]; }>; }; From a806b2eca60c7466e3aa899cbb6106df2ca978d9 Mon Sep 17 00:00:00 2001 From: Sander Bouwhuis Date: Sun, 26 Aug 2018 10:57:21 +0200 Subject: [PATCH 2/3] Add test for accessing property --- types/elasticsearch/elasticsearch-tests.ts | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/types/elasticsearch/elasticsearch-tests.ts b/types/elasticsearch/elasticsearch-tests.ts index 85574e3c91..c28db244f8 100644 --- a/types/elasticsearch/elasticsearch-tests.ts +++ b/types/elasticsearch/elasticsearch-tests.ts @@ -37,6 +37,14 @@ client.search({ }, (error) => { }); +client.search({ + q: 'pants' +}).then((body) => { + const hit = body.hits.hits[0]; + const names = hit && hit.matched_queries; +}, (error) => { +}); + client.indices.delete({ index: 'test_index', ignore: [404] From 324efba5130936e96bafb71cf93fdbc6cafa84ec Mon Sep 17 00:00:00 2001 From: Sander Bouwhuis Date: Mon, 27 Aug 2018 08:43:00 +0200 Subject: [PATCH 3/3] Update test --- types/elasticsearch/elasticsearch-tests.ts | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/types/elasticsearch/elasticsearch-tests.ts b/types/elasticsearch/elasticsearch-tests.ts index c28db244f8..68625bd5bb 100644 --- a/types/elasticsearch/elasticsearch-tests.ts +++ b/types/elasticsearch/elasticsearch-tests.ts @@ -38,8 +38,15 @@ client.search({ }); client.search({ - q: 'pants' -}).then((body) => { + body: { + query: { + match_all: { + _name: 'test' + } + } + } +} +).then((body) => { const hit = body.hits.hits[0]; const names = hit && hit.matched_queries; }, (error) => {