Bug 18235: (RM follow-up) fix mappings reset
authorNick Clemens <nick@bywatersolutions.com>
Thu, 28 Mar 2019 15:12:52 +0000 (15:12 +0000)
committerNick Clemens <nick@bywatersolutions.com>
Thu, 28 Mar 2019 15:18:48 +0000 (15:18 +0000)
Without this we could not recreate mappings as there are no defaults for
the additional fields - this restores behavoiur from before patches

Signed-off-by: Nick Clemens <nick@bywatersolutions.com>
Koha/SearchEngine/Elasticsearch.pm

index 5f9370d..81b1a8d 100644 (file)
@@ -285,11 +285,16 @@ sub reset_elasticsearch_mappings {
             my $field_label = $data->{label};
             my $mappings = $data->{mappings};
             my $facet_order = $data->{facet_order};
-            my $search_field = Koha::SearchFields->find_or_create({ name => $field_name });
+            my $search_field = Koha::SearchFields->find_or_create({ 
+                name  => $field_name,
+                label => $field_label,
+                type  => $field_type,
+            },
+            {
+                key => 'name'
+            });
             $search_field->update(
                 {
-                    label       => $field_label,
-                    type        => $field_type,
                     facet_order => $facet_order
                 }
             );