mirror of
https://gitlab.com/openstapps/openstapps.git
synced 2026-04-16 03:09:15 +00:00
refactor: move es-mapping-generator to monorepo
This commit is contained in:
59
packages/es-mapping-generator/src/config/fieldmap.ts
Normal file
59
packages/es-mapping-generator/src/config/fieldmap.ts
Normal file
@@ -0,0 +1,59 @@
|
||||
/*
|
||||
* 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 {ElasticsearchFieldmap, ElasticsearchFilterableMap} from '../types/mapping';
|
||||
import {ElasticsearchDataType} from './typemap';
|
||||
|
||||
export enum analyzers {
|
||||
ducet_sort = 'ducet_sort',
|
||||
search_german = 'search_german',
|
||||
}
|
||||
|
||||
export const fieldmap: ElasticsearchFieldmap = {
|
||||
aggregatable: {
|
||||
default: {
|
||||
raw: {
|
||||
ignore_above: 10000,
|
||||
type: ElasticsearchDataType.keyword,
|
||||
},
|
||||
},
|
||||
ignore: ['global'],
|
||||
},
|
||||
sortable: {
|
||||
default: {
|
||||
sort: {
|
||||
analyzer: analyzers.ducet_sort,
|
||||
fielddata: true,
|
||||
type: ElasticsearchDataType.text,
|
||||
},
|
||||
},
|
||||
ducet: {
|
||||
sort: {
|
||||
analyzer: analyzers.ducet_sort,
|
||||
fielddata: true,
|
||||
type: ElasticsearchDataType.text,
|
||||
},
|
||||
},
|
||||
ignore: ['price'],
|
||||
},
|
||||
};
|
||||
|
||||
export const filterableTagName = 'filterable';
|
||||
|
||||
export const filterableMap: ElasticsearchFilterableMap = {
|
||||
date: ElasticsearchDataType.keyword,
|
||||
keyword: ElasticsearchDataType.keyword,
|
||||
text: ElasticsearchDataType.keyword,
|
||||
integer: ElasticsearchDataType.integer,
|
||||
};
|
||||
69
packages/es-mapping-generator/src/config/premap.ts
Normal file
69
packages/es-mapping-generator/src/config/premap.ts
Normal file
@@ -0,0 +1,69 @@
|
||||
/*
|
||||
* 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 {ElasticsearchPremap} from '../types/mapping';
|
||||
import {ElasticsearchDataType} from './typemap';
|
||||
|
||||
export const premaps: ElasticsearchPremap = {
|
||||
CoordinateReferenceSystem: {
|
||||
dynamic: true,
|
||||
properties: {
|
||||
type: {
|
||||
type: ElasticsearchDataType.keyword,
|
||||
},
|
||||
},
|
||||
},
|
||||
LineString: {
|
||||
precision: '1m',
|
||||
tree: 'quadtree',
|
||||
type: ElasticsearchDataType.geo_shape,
|
||||
},
|
||||
Point: {
|
||||
properties: {
|
||||
type: {
|
||||
type: ElasticsearchDataType.keyword,
|
||||
},
|
||||
coordinates: {
|
||||
type: ElasticsearchDataType.geo_point,
|
||||
},
|
||||
},
|
||||
dynamic: 'strict',
|
||||
},
|
||||
Polygon: {
|
||||
precision: '1m',
|
||||
tree: 'quadtree',
|
||||
type: ElasticsearchDataType.geo_shape,
|
||||
},
|
||||
SCISO8601DateRange: {
|
||||
type: ElasticsearchDataType.date_range,
|
||||
},
|
||||
'jsonpatch.OpPatch': {
|
||||
dynamic: 'strict',
|
||||
properties: {
|
||||
from: {
|
||||
type: ElasticsearchDataType.keyword,
|
||||
},
|
||||
op: {
|
||||
type: ElasticsearchDataType.keyword,
|
||||
},
|
||||
path: {
|
||||
type: ElasticsearchDataType.keyword,
|
||||
},
|
||||
value: {
|
||||
// this is actually an 'any' type, however ES does not really support that.
|
||||
type: ElasticsearchDataType.keyword,
|
||||
},
|
||||
},
|
||||
},
|
||||
};
|
||||
65
packages/es-mapping-generator/src/config/settings.ts
Normal file
65
packages/es-mapping-generator/src/config/settings.ts
Normal file
@@ -0,0 +1,65 @@
|
||||
/*
|
||||
* 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 {ElasticsearchSettings} from '../types/mapping';
|
||||
|
||||
export const settings: ElasticsearchSettings = {
|
||||
analysis: {
|
||||
analyzer: {
|
||||
ducet_sort: {
|
||||
filter: [
|
||||
'german_phonebook',
|
||||
],
|
||||
tokenizer: 'keyword',
|
||||
type: 'custom',
|
||||
},
|
||||
search_german: {
|
||||
filter: [
|
||||
'lowercase',
|
||||
'german_stop',
|
||||
'german_stemmer',
|
||||
],
|
||||
tokenizer: 'stapps_ngram',
|
||||
type: 'custom',
|
||||
},
|
||||
},
|
||||
filter: {
|
||||
german_phonebook: {
|
||||
country: 'DE',
|
||||
language: 'de',
|
||||
type: 'icu_collation',
|
||||
variant: '@collation=phonebook',
|
||||
},
|
||||
german_stemmer: {
|
||||
language: 'german',
|
||||
type: 'stemmer',
|
||||
},
|
||||
german_stop: {
|
||||
stopwords: '_german_',
|
||||
type: 'stop',
|
||||
},
|
||||
},
|
||||
tokenizer: {
|
||||
stapps_ngram: {
|
||||
max_gram: 7,
|
||||
min_gram: 4,
|
||||
type: 'ngram',
|
||||
},
|
||||
},
|
||||
},
|
||||
'mapping.total_fields.limit': 10000,
|
||||
max_result_window: 30000,
|
||||
number_of_replicas: 0,
|
||||
number_of_shards: 1,
|
||||
};
|
||||
83
packages/es-mapping-generator/src/config/typemap.ts
Normal file
83
packages/es-mapping-generator/src/config/typemap.ts
Normal file
@@ -0,0 +1,83 @@
|
||||
/*
|
||||
* 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 {ElasticsearchTypemap} from '../types/mapping';
|
||||
|
||||
export enum ElasticsearchDataType {
|
||||
missing_premap = 'MISSING_PREMAP',
|
||||
parse_error = 'PARSE_ERROR',
|
||||
type_conflict = 'TYPE_CONFLICT',
|
||||
text = 'text',
|
||||
keyword = 'keyword',
|
||||
date = 'date',
|
||||
// long = 'long',
|
||||
// double = 'double',
|
||||
float = 'float',
|
||||
boolean = 'boolean',
|
||||
ip = 'ip',
|
||||
integer = 'integer',
|
||||
object = 'object',
|
||||
nested = 'nested',
|
||||
geo_point = 'geo_point',
|
||||
geo_shape = 'geo_shape',
|
||||
completion = 'completion',
|
||||
date_range = 'date_range',
|
||||
// integer_range = 'integer_range',
|
||||
// float_range = 'float_range',
|
||||
// long_range = 'long_range',
|
||||
// double_range = 'double_range',
|
||||
// ip_range = 'ip_range',
|
||||
}
|
||||
|
||||
export const typemap: ElasticsearchTypemap = {
|
||||
boolean: {
|
||||
default: ElasticsearchDataType.boolean,
|
||||
},
|
||||
false: {
|
||||
default: ElasticsearchDataType.boolean,
|
||||
},
|
||||
number: {
|
||||
default: ElasticsearchDataType.integer,
|
||||
float: ElasticsearchDataType.float,
|
||||
integer: ElasticsearchDataType.integer,
|
||||
date: ElasticsearchDataType.date,
|
||||
},
|
||||
string: {
|
||||
default: ElasticsearchDataType.text,
|
||||
keyword: ElasticsearchDataType.keyword,
|
||||
text: ElasticsearchDataType.text,
|
||||
date: ElasticsearchDataType.date,
|
||||
},
|
||||
stringLiteral: {
|
||||
default: ElasticsearchDataType.keyword,
|
||||
},
|
||||
true: {
|
||||
default: ElasticsearchDataType.boolean,
|
||||
},
|
||||
};
|
||||
|
||||
/**
|
||||
* If the string is a tag type
|
||||
*/
|
||||
export function isTagType(str: string): boolean {
|
||||
for (const key in typemap) {
|
||||
if (typemap.hasOwnProperty(key) && typeof typemap[key][str] !== 'undefined') {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
export const dynamicTypes = ['any', 'unknown'];
|
||||
Reference in New Issue
Block a user