From 3921820ae8b9466d6dca558bd83e477e501f620b Mon Sep 17 00:00:00 2001 From: Martin Edenhofer Date: Wed, 4 Dec 2019 10:52:54 +0100 Subject: [PATCH] Fixes #2824 - Elasticsearch 7.5.x support. --- lib/tasks/search_index_es.rake | 35 +++++++++++++++++++++------------- 1 file changed, 22 insertions(+), 13 deletions(-) diff --git a/lib/tasks/search_index_es.rake b/lib/tasks/search_index_es.rake index 6d588d394..860d15206 100644 --- a/lib/tasks/search_index_es.rake +++ b/lib/tasks/search_index_es.rake @@ -79,6 +79,18 @@ namespace :searchindex do pipeline = "zammad#{rand(999_999_999_999)}" Setting.set('es_pipeline', pipeline) end + + # define pipeline_field_attributes + # ES 5.6 and nower has no ignore_missing support + pipeline_field_attributes = { + ignore_failure: true, + } + if es_multi_index? + pipeline_field_attributes = { + ignore_failure: true, + ignore_missing: true, + } + end print 'create pipeline (pipeline)... ' SearchIndexBackend.processors( "_ingest/pipeline/#{pipeline}": [ @@ -91,22 +103,19 @@ namespace :searchindex do processors: [ { foreach: { - field: 'article', - ignore_failure: true, - processor: { + field: 'article', + processor: { foreach: { - field: '_ingest._value.attachment', - ignore_failure: true, - processor: { + field: '_ingest._value.attachment', + processor: { attachment: { - target_field: '_ingest._value', - field: '_ingest._value._content', - ignore_failure: true, - } + target_field: '_ingest._value', + field: '_ingest._value._content', + }.merge(pipeline_field_attributes), } - } + }.merge(pipeline_field_attributes), } - } + }.merge(pipeline_field_attributes), } ] } @@ -301,7 +310,7 @@ def es_pipeline? true end -# no mulit index for elasticsearch 5.6 and lower +# no multi index for elasticsearch 5.6 and lower def es_multi_index? number = es_version return false if number.blank?