mirror of
https://gitlab.com/openstapps/openstapps.git
synced 2026-01-21 09:03:02 +00:00
refactor: move es-mapping-generator to monorepo
This commit is contained in:
55
packages/es-mapping-generator/src/config/fieldmap.ts
Normal file
55
packages/es-mapping-generator/src/config/fieldmap.ts
Normal file
@@ -0,0 +1,55 @@
|
||||
/*
|
||||
* 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 <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
import {MappingProperty} from '@elastic/elasticsearch/lib/api/types';
|
||||
import {ElasticsearchFieldmap, SimpleType} from '../types/mapping';
|
||||
|
||||
const ducetSort = {
|
||||
type: 'icu_collation_keyword',
|
||||
language: 'de',
|
||||
country: 'DE',
|
||||
variant: '@collation=phonebook',
|
||||
};
|
||||
|
||||
const keyword: MappingProperty['type'] = 'keyword';
|
||||
|
||||
export const fieldmap: ElasticsearchFieldmap = {
|
||||
aggregatable: {
|
||||
default: {
|
||||
raw: {
|
||||
ignore_above: 10_000,
|
||||
type: keyword,
|
||||
},
|
||||
},
|
||||
ignore: ['global'],
|
||||
},
|
||||
sortable: {
|
||||
default: {
|
||||
sort: ducetSort,
|
||||
},
|
||||
ducet: {
|
||||
sort: ducetSort,
|
||||
},
|
||||
ignore: ['price'],
|
||||
},
|
||||
};
|
||||
|
||||
export const filterableTagName = 'filterable';
|
||||
|
||||
export const filterableMap: Record<string, SimpleType> = {
|
||||
date: 'keyword',
|
||||
keyword: 'keyword',
|
||||
text: 'keyword',
|
||||
integer: 'integer',
|
||||
};
|
||||
64
packages/es-mapping-generator/src/config/premap.ts
Normal file
64
packages/es-mapping-generator/src/config/premap.ts
Normal file
@@ -0,0 +1,64 @@
|
||||
/*
|
||||
* 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 <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
import {MappingProperty} from '@elastic/elasticsearch/lib/api/types';
|
||||
|
||||
export const premaps: Record<string, MappingProperty> = {
|
||||
'CoordinateReferenceSystem': {
|
||||
dynamic: true,
|
||||
properties: {
|
||||
type: {
|
||||
type: 'keyword',
|
||||
},
|
||||
},
|
||||
},
|
||||
'LineString': {
|
||||
type: 'geo_shape',
|
||||
},
|
||||
'Point': {
|
||||
properties: {
|
||||
type: {
|
||||
type: 'keyword',
|
||||
},
|
||||
coordinates: {
|
||||
type: 'geo_point',
|
||||
},
|
||||
},
|
||||
dynamic: 'strict',
|
||||
},
|
||||
'Polygon': {
|
||||
type: 'geo_shape',
|
||||
},
|
||||
'SCISO8601DateRange': {
|
||||
type: 'date_range',
|
||||
},
|
||||
'jsonpatch.OpPatch': {
|
||||
dynamic: 'strict',
|
||||
properties: {
|
||||
from: {
|
||||
type: 'keyword',
|
||||
},
|
||||
op: {
|
||||
type: 'keyword',
|
||||
},
|
||||
path: {
|
||||
type: 'keyword',
|
||||
},
|
||||
value: {
|
||||
// this is actually an 'any' type; however, ES does not really support that.
|
||||
type: 'keyword',
|
||||
},
|
||||
},
|
||||
},
|
||||
};
|
||||
22
packages/es-mapping-generator/src/config/settings.ts
Normal file
22
packages/es-mapping-generator/src/config/settings.ts
Normal file
@@ -0,0 +1,22 @@
|
||||
/*
|
||||
* 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 <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
import {IndicesPutTemplateRequest} from '@elastic/elasticsearch/lib/api/types';
|
||||
|
||||
export const settings: IndicesPutTemplateRequest['settings'] = {
|
||||
'mapping.total_fields.limit': 10_000,
|
||||
'max_result_window': 30_000,
|
||||
'number_of_replicas': 0,
|
||||
'number_of_shards': 1,
|
||||
};
|
||||
62
packages/es-mapping-generator/src/config/typemap.ts
Normal file
62
packages/es-mapping-generator/src/config/typemap.ts
Normal file
@@ -0,0 +1,62 @@
|
||||
/*
|
||||
* 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 <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
import {MappingFloatNumberProperty} from '@elastic/elasticsearch/lib/api/types';
|
||||
import {ElasticsearchTypemap} from '../types/mapping';
|
||||
|
||||
export const PARSE_ERROR = 'PARSE_ERROR' as MappingFloatNumberProperty['type'];
|
||||
export const MISSING_PREMAP = 'MISSING_PREMAP' as MappingFloatNumberProperty['type'];
|
||||
export const TYPE_CONFLICT = 'TYPE_CONFLICT' as MappingFloatNumberProperty['type'];
|
||||
|
||||
export const typemap: ElasticsearchTypemap = {
|
||||
boolean: {
|
||||
default: 'boolean',
|
||||
},
|
||||
false: {
|
||||
default: 'boolean',
|
||||
},
|
||||
number: {
|
||||
default: 'integer',
|
||||
float: 'float',
|
||||
integer: 'integer',
|
||||
date: 'date',
|
||||
},
|
||||
string: {
|
||||
default: 'text',
|
||||
keyword: 'keyword',
|
||||
text: 'text',
|
||||
date: 'date',
|
||||
},
|
||||
stringLiteral: {
|
||||
default: 'keyword',
|
||||
},
|
||||
true: {
|
||||
default: 'boolean',
|
||||
},
|
||||
};
|
||||
|
||||
/**
|
||||
* If the string is a tag type
|
||||
*/
|
||||
export function isTagType(string_: string): boolean {
|
||||
for (const key in typemap) {
|
||||
if (typemap.hasOwnProperty(key) && typeof typemap[key][string_] !== 'undefined') {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
export const dynamicTypes = ['any', 'unknown'];
|
||||
Reference in New Issue
Block a user