Browse Source

Fixes #2824 - Elasticsearch 7.5.x support.

Martin Edenhofer 5 years ago
parent
commit
3921820ae8
1 changed files with 22 additions and 13 deletions
  1. 22 13
      lib/tasks/search_index_es.rake

+ 22 - 13
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?