Bug 36396: Export/import the yaml config

Test plan:
Export the ES fields/mappings using
 misc/search_tools/export_elasticsearch_mappings.pl > mappings.yaml
Copy this file to admin/searchengine/elasticsearch/mappings.yaml

Reset the mapping from the UI
Notice that the links to the AV categories have been preserved

Sponsored-by: The Research University in the Helmholtz Association (KIT)
Signed-off-by: Lukas Koszyk <lukasz.koszyk@kit.edu>
Signed-off-by: Martin Renvoize <martin.renvoize@ptfs-europe.com>
Signed-off-by: Katrin Fischer <katrin.fischer@bsz-bw.de>
This commit is contained in:
Jonathan Druart 2024-03-22 10:04:08 +01:00 committed by Katrin Fischer
parent 621ad21a7a
commit 5561383a9f
Signed by: kfischer
GPG key ID: 0EF6E2C03357A834

View file

@ -288,6 +288,9 @@ sub raw_elasticsearch_mappings {
$mappings->{ $marc_map->index_name }{ $search_field->name }{type} = $search_field->type;
$mappings->{ $marc_map->index_name }{ $search_field->name }{mandatory} = $search_field->mandatory;
$mappings->{ $marc_map->index_name }{ $search_field->name }{facet_order} = $search_field->facet_order if defined $search_field->facet_order;
$mappings->{ $marc_map->index_name }{ $search_field->name }{authorised_value_category} =
$search_field->authorised_value_category
if defined $search_field->authorised_value_category;
$mappings->{ $marc_map->index_name }{ $search_field->name }{weight} = $search_field->weight if defined $search_field->weight;
$mappings->{ $marc_map->index_name }{ $search_field->name }{opac} = $search_field->opac if defined $search_field->opac;
$mappings->{ $marc_map->index_name }{ $search_field->name }{staff_client} = $search_field->staff_client if defined $search_field->staff_client;
@ -368,7 +371,7 @@ sub reset_elasticsearch_mappings {
while ( my ( $index_name, $fields ) = each %$indexes ) {
while ( my ( $field_name, $data ) = each %$fields ) {
my %sf_params = map { $_ => $data->{$_} } grep { exists $data->{$_} } qw/ type label weight staff_client opac facet_order mandatory/;
my %sf_params = map { $_ => $data->{$_} } grep { exists $data->{$_} } qw/ type label weight staff_client opac facet_order authorised_value_category mandatory/;
# Set default values
$sf_params{staff_client} //= 1;