fix: make mapping tags work for overwritten values

This commit is contained in:
Wieland Schöbl
2019-09-23 13:28:21 +02:00
parent 18ad651286
commit 47361d412a
7 changed files with 35406 additions and 101 deletions

View File

@@ -0,0 +1,81 @@
/*
* Copyright (C) 2019 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 <https://www.gnu.org/licenses/>.
*/
/**
* 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
*/
type: {
/**
* The name of the type
*/
value: string;
};
}
/**
* Filter that matches everything
*/
export interface ESAggMatchAllFilter {
/**
* Filter that matches everything
*/
match_all: {};
}
/**
* For nested aggregations
*/
export interface ESNestedAggregation {
/**
* Possible nested Aggregations
*/
aggs: AggregationSchema;
/**
* Possible filter for types
*/
filter: ESAggTypeFilter | ESAggMatchAllFilter;
}

View File

@@ -28,7 +28,7 @@ export const fieldmap: ElasticsearchFieldmap = {
type: ElasticsearchDataType.keyword,
},
},
ignore: [],
ignore: ['global'],
},
sortable: {
default: {

View File

@@ -18,69 +18,24 @@ import {ElasticsearchDataType} from './typemap';
export const premaps: ElasticsearchPremap = {
CoordinateReferenceSystem: {
dynamic: 'strict',
properties: {
properties: {
dynamic: true,
properties: {},
},
type: {
type: ElasticsearchDataType.keyword,
},
},
precision: '1m',
tree: 'quadtree',
type: ElasticsearchDataType.geo_shape,
},
LineString: {
dynamic: 'strict',
properties: {
coordinates: {
type: ElasticsearchDataType.float,
},
type: {
type: ElasticsearchDataType.keyword,
},
},
precision: '1m',
tree: 'quadtree',
type: ElasticsearchDataType.geo_shape,
},
Point: {
dynamic: 'strict',
properties: {
bbox: {type: ElasticsearchDataType.float},
coordinates: {
fields: {raw: {type: ElasticsearchDataType.keyword}},
type: ElasticsearchDataType.geo_point,
},
crs: {
dynamic: 'strict',
properties: {
properties: {
dynamic: true,
properties: {},
},
type: {type: ElasticsearchDataType.keyword},
},
},
type: {type: ElasticsearchDataType.keyword},
},
precision: '1m',
tree: 'quadtree',
type: ElasticsearchDataType.geo_shape,
},
Polygon: { // a Polygon is mapped the same way as a Point is, you can just copy & paste
dynamic: 'strict',
properties: {
bbox: {type: ElasticsearchDataType.float},
coordinates: {
fields: {raw: {type: ElasticsearchDataType.keyword}},
type: ElasticsearchDataType.geo_point,
},
crs: {
dynamic: 'strict',
properties: {
properties: {
dynamic: true,
properties: {},
},
type: {type: ElasticsearchDataType.keyword},
},
},
type: {type: ElasticsearchDataType.keyword},
},
Polygon: {
precision: '1m',
tree: 'quadtree',
type: ElasticsearchDataType.geo_shape,
},
'jsonpatch.OpPatch': {
dynamic: 'strict',

View File

@@ -22,7 +22,7 @@ import {ElasticsearchDataType} from './definitions/typemap';
* Both are composed similarly, and can be the value of a propery
* of an Elasticsearch Object.
*/
export type ElasticsearchValue = ElasticsearchType | ElasticsearchObject;
export type ElasticsearchValue = ElasticsearchType | ElasticsearchObject | ElasticsearchGeoShape;
/**
* Used internally for saving a generic value contained in a reflection
@@ -178,12 +178,61 @@ export interface ElasticsearchType {
type: ElasticsearchDataType;
}
/**
* A GeoShape data type
*
* https://www.elastic.co/guide/en/elasticsearch/reference/5.6/geo-shape.html
*/
export interface ElasticsearchGeoShape {
/**
* Does not exist; here for TypeScript compiler
*/
fields?: undefined;
/**
* This parameter may be used instead of tree_levels to set an appropriate value for the tree_levels parameter.
*
* The value specifies the desired precision and Elasticsearch will calculate the best tree_levels value to honor
* this precision. The value should be a number followed by an optional distance unit. Valid distance units include:
* in, inch, yd, yard, mi, miles, km, kilometers, m,meters, cm,centimeters, mm, millimeters.
*/
precision: string;
/**
* Name of the PrefixTree implementation to be used: geohash for GeohashPrefixTree and quadtree for QuadPrefixTree.
*/
tree: 'quadtree' | 'geohash';
/**
* The type of the object, obviously geo_shape
*/
type: ElasticsearchDataType.geo_shape;
}
/**
* An object data type
*
* https://www.elastic.co/guide/en/elasticsearch/reference/5.6/object.html
*/
export interface ElasticsearchObject {
/**
* Only for the top type
*/
_source?: {
/**
* Fields that should be excluded in the _source field
*/
excludes: [
'creation_date',
];
};
/**
* Whether the creation date should be set automatically
*/
date_detection?: boolean;
/**
* If the object is a dynamic
*
@@ -224,6 +273,13 @@ export interface ElasticsearchObject {
};
}
export type ElasticsearchMapping = ElasticsearchObject;
// TODO: docs
export interface ElasticsearchMappings {
[indexName: string]: ElasticsearchMapping;
}
/**
* An Elasticsearch template
*