From 2a7faa683c4a80cb6f0a76f0dcc3180a79317911 Mon Sep 17 00:00:00 2001 From: Nicolas Biehler Date: Fri, 23 Nov 2018 15:35:35 +0100 Subject: [PATCH 1/2] fix: extend elasticsearch alias params As shown in elasticsearch documentation (https://www.elastic.co/guide/en/elasticsearch/reference/current/indices-aliases.html#filtered), an alias can have a routing value and a filter specified. --- types/elasticsearch/index.d.ts | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/types/elasticsearch/index.d.ts b/types/elasticsearch/index.d.ts index 0d16cc6a4b..62202dbc90 100644 --- a/types/elasticsearch/index.d.ts +++ b/types/elasticsearch/index.d.ts @@ -1400,11 +1400,15 @@ export interface IndicesUpdateAliasesParamsAction { index?: string; indices?: string[]; alias: string; + routing?: string; + filter?: object; }; remove?: { index?: string; indices?: string[]; alias: string; + routing?: string; + filter?: object; }; remove_index?: { index: string; From 37d0e8c735d8573f238b51461fb3489190274def Mon Sep 17 00:00:00 2001 From: Nicolas Biehler Date: Fri, 23 Nov 2018 15:35:35 +0100 Subject: [PATCH 2/2] fix: extend elasticsearch alias params As shown in elasticsearch documentation (https://www.elastic.co/guide/en/elasticsearch/reference/current/indices-aliases.html#filtered), an alias can have a routing value and a filter specified. --- types/elasticsearch/elasticsearch-tests.ts | 43 ++++++++++++++++------ types/elasticsearch/index.d.ts | 2 - 2 files changed, 32 insertions(+), 13 deletions(-) diff --git a/types/elasticsearch/elasticsearch-tests.ts b/types/elasticsearch/elasticsearch-tests.ts index ee57f847fa..0d12a931ed 100644 --- a/types/elasticsearch/elasticsearch-tests.ts +++ b/types/elasticsearch/elasticsearch-tests.ts @@ -209,7 +209,7 @@ client.get({ id: '1', routing: '1' }, (error, response) => { - const routing = response._routing; + const routing = response._routing; }); client.mget({ @@ -338,22 +338,43 @@ client.indices.updateAliases({ // ... }); -client.reindex({ - body: { - source: { - index: "twitter" - }, - dest: { - index: "new_twitter" +client.indices.updateAliases({ + body: { + actions: [ + { + add: { + index: 'logstash-2018.11', alias: 'logstash-filtered', filter: { + query: { + exists: { field: 'id' } + } + }, + routing: 'id' } } + ] + } +}).then((response) => { + // ... +}, (error) => { + // ... +}); + +client.reindex({ + body: { + source: { + index: "twitter" + }, + dest: { + index: "new_twitter" + } + } }) -.then(response => { + .then(response => { const { took, timed_out } = response; // ... -}); + }); // Errors function testErrors() { - throw new elasticsearch.errors.AuthenticationException(); + throw new elasticsearch.errors.AuthenticationException(); } diff --git a/types/elasticsearch/index.d.ts b/types/elasticsearch/index.d.ts index 62202dbc90..401627d2c1 100644 --- a/types/elasticsearch/index.d.ts +++ b/types/elasticsearch/index.d.ts @@ -1407,8 +1407,6 @@ export interface IndicesUpdateAliasesParamsAction { index?: string; indices?: string[]; alias: string; - routing?: string; - filter?: object; }; remove_index?: { index: string;