Поддерживает ли Mongo-соединитель добавление полей перед вставкой в Elasticsearch?
У меня много дел в mongoDB. Mongo-разъем вставляет эти данные в эластичный поиск. Есть ли способ, прежде чем вставить в ES, где мы можем добавить дополнительное поле в документ, а затем вставить в эластичный поиск? Есть ли способ в монго-разъеме сделать выше?
ОБНОВИТЬ
основываясь на вашемОБНОВЛЕНИЕ 3 я создал сопоставления что-то вроде этого, это правильно?
PUT my_index2
{
"mappings":{
"my_type2": {
"transform": {
"script": {
"inline": "if (ctx._source.geopoint.alt) ctx._source.geopoint.remove('alt')",
"lang": "groovy"
}
},
"properties": {
"geopoint": {
"type": "geo_point"
}
}
}
}
}
ОШИБКА
Это ошибка, которую я получаю, когда пытаюсь вставить ваше отображение
{
"error": {
"root_cause": [
{
"type": "script_parse_exception",
"reason": "Value must be of type String: [script]"
}
],
"type": "mapper_parsing_exception",
"reason": "Failed to parse mapping [my_type2]: Value must be of type String: [script]",
"caused_by": {
"type": "script_parse_exception",
"reason": "Value must be of type String: [script]"
}
},
"status": 400
}
ОБНОВЛЕНИЕ 2
Теперь отображение вставляется и получает подтверждение как истинное. Но когда попробуйте вставить данные JSON, как показано ниже, их ошибка.
PUT my_index2/my_type2/1
{
"geopoint": {
"lon": 48.845877,
"lat": 8.821861,
"alt": 0.0
}
}
ОШИБКА ОБНОВЛЕНИЯ2
{
"error": {
"root_cause": [
{
"type": "mapper_parsing_exception",
"reason": "failed to parse"
}
],
"type": "mapper_parsing_exception",
"reason": "failed to parse",
"caused_by": {
"type": "illegal_argument_exception",
"reason": "failed to execute script",
"caused_by": {
"type": "script_exception",
"reason": "scripts of type [inline], operation [mapping] and lang [groovy] are disabled"
}
}
},
"status": 400
}
ОШИБКА 1 ДЛЯ ОБНОВЛЕНИЯ 2
После добавления script.inline: true попытался вставить данные, но получил следующую ошибку.
{
"error": {
"root_cause": [
{
"type": "parse_exception",
"reason": "field must be either [lat], [lon] or [geohash]"
}
],
"type": "mapper_parsing_exception",
"reason": "failed to parse",
"caused_by": {
"type": "parse_exception",
"reason": "field must be either [lat], [lon] or [geohash]"
}
},
"status": 400
}