From 9972085a93501bb9e85ee47a334a379c676c2487 Mon Sep 17 00:00:00 2001 From: Nick Clemens Date: Fri, 1 Sep 2023 12:40:15 +0000 Subject: [PATCH] Bug 27153: Interface updates This patch adds a new column to the 'Bibliographic records' tab in Administration > Search engine configuration (Elasticsearch) To test: 1 - Confirm the new 'filter' column shows 2 - Update an existing field to set filter to punctuation 3 - Confirm it can be saved 4 - Add a new field 5 - Confirm it saves correctly 6 - Unset filter for a field 7 - Confirm it saves Signed-off-by: Danielle M Elder Signed-off-by: Martin Renvoize Signed-off-by: Tomas Cohen Arazi --- admin/searchengine/elasticsearch/mappings.pl | 29 ++++++++++++------- .../searchengine/elasticsearch/mappings.tt | 26 +++++++++++++++++ 2 files changed, 45 insertions(+), 10 deletions(-) diff --git a/admin/searchengine/elasticsearch/mappings.pl b/admin/searchengine/elasticsearch/mappings.pl index 10302624d3..370c698265 100755 --- a/admin/searchengine/elasticsearch/mappings.pl +++ b/admin/searchengine/elasticsearch/mappings.pl @@ -103,6 +103,7 @@ if ( $op eq 'edit' ) { my @mapping_facet = $input->multi_param('mapping_facet'); my @mapping_suggestible = $input->multi_param('mapping_suggestible'); my @mapping_search = $input->multi_param('mapping_search'); + my @mapping_filter = $input->multi_param('mapping_filter'); my @mapping_marc_field = $input->multi_param('mapping_marc_field'); my @faceted_field_names = $input->multi_param('display_facet'); @@ -153,6 +154,7 @@ if ( $op eq 'edit' ) { my $mapping_suggestible = $mapping_suggestible[$i]; my $mapping_sort = $mapping_sort[$i]; my $mapping_search = $mapping_search[$i]; + my $mapping_filter = $mapping_filter[$i]; my $search_field = Koha::SearchFields->find({ name => $search_field_name }, { key => 'name' }); $mandatory_after++ if $search_field->mandatory && !defined $seen_fields{$search_field_name}; @@ -166,12 +168,16 @@ if ( $op eq 'edit' ) { marc_type => $marc_type, marc_field => $mapping_marc_field }); - $search_field->add_to_search_marc_maps($marc_field, { - facet => $mapping_facet, - suggestible => $mapping_suggestible, - sort => $mapping_sort, - search => $mapping_search - }); + $search_field->add_to_search_marc_maps( + $marc_field, + { + facet => $mapping_facet, + suggestible => $mapping_suggestible, + sort => $mapping_sort, + search => $mapping_search, + filter => $mapping_filter + } + ); } push @errors, { type => 'error', code => 'missing_mandatory_fields' } if $mandatory_after < $mandatory_before; }; @@ -227,15 +233,16 @@ for my $index_name (@index_names) { my $search_fields = Koha::SearchFields->search( { 'search_marc_map.index_name' => $index_name, - 'search_marc_map.marc_type' => $marc_type, + 'search_marc_map.marc_type' => $marc_type, }, { - join => { search_marc_to_fields => 'search_marc_map' }, + join => { search_marc_to_fields => 'search_marc_map' }, '+select' => [ 'search_marc_to_fields.facet', 'search_marc_to_fields.suggestible', 'search_marc_to_fields.sort', 'search_marc_to_fields.search', + 'search_marc_to_fields.filter', 'search_marc_map.marc_field' ], '+as' => [ @@ -243,11 +250,12 @@ for my $index_name (@index_names) { 'suggestible', 'sort', 'search', + 'filter', 'marc_field' ], order_by => { -asc => [qw/name marc_field/] } - } - ); + } + ); my @mappings; my @facetable_field_names = map { $_->name } @facetable_fields; @@ -263,6 +271,7 @@ for my $index_name (@index_names) { sort => $s->get_column('sort') // 'undef', # To avoid warnings "Use of uninitialized value in lc" suggestible => $s->get_column('suggestible'), search => $s->get_column('search'), + filter => $s->get_column('filter'), facet => $s->get_column('facet'), is_facetable => ( grep { $_ eq $name } @facetable_field_names ) ? 1 : 0, }; diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/admin/searchengine/elasticsearch/mappings.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/admin/searchengine/elasticsearch/mappings.tt index 1990c52e6d..242eae6758 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/modules/admin/searchengine/elasticsearch/mappings.tt +++ b/koha-tmpl/intranet-tmpl/prog/en/modules/admin/searchengine/elasticsearch/mappings.tt @@ -267,6 +267,7 @@ a.add, a.delete { Facetable Suggestible Searchable + Filter Mapping   @@ -297,6 +298,9 @@ a.add, a.delete { [% IF mapping.search == 1 %]Yes[% ELSE %]No[% END %] + + [% IF mapping.filter == 'punctuation' %]Punctuation[% END %] + @@ -359,6 +363,17 @@ a.add, a.delete { [% END %] + + + @@ -420,6 +435,17 @@ a.add, a.delete { [% END %] + + + Add -- 2.39.5