From 5be8b6d5c23c2e339dda03467b5693e876bcead9 Mon Sep 17 00:00:00 2001 From: Jan Oberhauser Date: Sun, 18 Jul 2021 14:21:30 +0200 Subject: [PATCH] :zap: Add also "simple" option to Document->GetAll --- .../nodes/Elasticsearch/Elasticsearch.node.ts | 11 +++++++++++ .../descriptions/DocumentDescription.ts | 17 +++++++++++++++++ 2 files changed, 28 insertions(+) diff --git a/packages/nodes-base/nodes/Elasticsearch/Elasticsearch.node.ts b/packages/nodes-base/nodes/Elasticsearch/Elasticsearch.node.ts index 6ef02e518d..6e2876094c 100644 --- a/packages/nodes-base/nodes/Elasticsearch/Elasticsearch.node.ts +++ b/packages/nodes-base/nodes/Elasticsearch/Elasticsearch.node.ts @@ -169,6 +169,17 @@ export class Elasticsearch implements INodeType { responseData = await elasticsearchApiRequest.call(this, 'GET', `/${indexId}/_search`, body, qs); responseData = responseData.hits.hits; + const simple = this.getNodeParameter('simple', 0) as IDataObject; + + if (simple) { + responseData = responseData.map((item: IDataObject) => { + return { + _id: item._id, + ...(item._source as Object), + }; + }); + } + } else if (operation === 'create') { // ---------------------------------------- diff --git a/packages/nodes-base/nodes/Elasticsearch/descriptions/DocumentDescription.ts b/packages/nodes-base/nodes/Elasticsearch/descriptions/DocumentDescription.ts index dca8122caa..24c0519206 100644 --- a/packages/nodes-base/nodes/Elasticsearch/descriptions/DocumentDescription.ts +++ b/packages/nodes-base/nodes/Elasticsearch/descriptions/DocumentDescription.ts @@ -247,6 +247,23 @@ export const documentFields = [ }, }, }, + { + displayName: 'Simple', + name: 'simple', + type: 'boolean', + default: true, + description: 'Whether to return a simplified version of the response instead of the raw data', + displayOptions: { + show: { + resource: [ + 'document', + ], + operation: [ + 'getAll', + ], + }, + }, + }, { displayName: 'Options', name: 'options',