From 522b9514900c280fa1c45b22e25860fb9afbfe1c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Thea=20Sch=C3=B6bl?= Date: Wed, 24 May 2023 13:31:41 +0200 Subject: [PATCH] refactor: update es-mapping-generator --- .../src/types/aggregation.ts | 82 +++++++++++++++++++ 1 file changed, 82 insertions(+) diff --git a/packages/es-mapping-generator/src/types/aggregation.ts b/packages/es-mapping-generator/src/types/aggregation.ts index e69de29b..7972008a 100644 --- a/packages/es-mapping-generator/src/types/aggregation.ts +++ b/packages/es-mapping-generator/src/types/aggregation.ts @@ -0,0 +1,82 @@ +/* + * Copyright (C) 2019-2021 StApps + * This program is free software: you can redistribute it and/or modify it + * under the terms of the GNU General Public License as published by the Free + * Software Foundation, version 3. + * + * This program is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for + * more details. + * + * You should have received a copy of the GNU General Public License along with + * this program. If not, see . + */ + +/** + * An elasticsearch bucket aggregation + * + * @see https://www.elastic.co/guide/en/elasticsearch/reference/5.6/search-aggregations-bucket.html + */ +export interface AggregationSchema { + [aggregationName: string]: ESTermsFilter | ESNestedAggregation; +} + +/** + * An elasticsearch terms filter + */ +export interface ESTermsFilter { + /** + * Terms filter definition + */ + terms: { + /** + * Field to apply filter to + */ + field: string; + + /** + * Number of results + */ + size?: number; + }; +} + +/** + * Filter that filters by name of the the field type + */ +export interface ESAggTypeFilter { + /** + * The type of the object to find + */ + term: { + /** + * The name of the type + */ + type: string; + }; +} + +/** + * Filter that matches everything + */ +export interface ESAggMatchAllFilter { + /** + * Filter that matches everything + */ + match_all: object; +} + +/** + * For nested aggregations + */ +export interface ESNestedAggregation { + /** + * Possible nested Aggregations + */ + aggs: AggregationSchema; + /** + * Possible filter for types + */ + filter: ESAggTypeFilter | ESAggMatchAllFilter; +}