From 19eed6dbfc3506b34ffc015b337046d9317c3c1d Mon Sep 17 00:00:00 2001 From: Emmi Takkinen Date: Mon, 6 Nov 2023 08:34:46 +0200 Subject: [PATCH] Bug 17897: Add search_marc_to_field.filter to SearhMappingManager Methods in SearchMappingManager didn't take into account search_marc_to_field.filter indtroduced in bug 27153. To test, prove t/db_dependent/Koha/SearchEngine/ElasticSearch.t Sponsored-by: Koha-Suomi Oy --- Koha/SearchMappingManager.pm | 9 +++++++-- t/db_dependent/Koha/SearchEngine/ElasticSearch.t | 12 ++++++++---- 2 files changed, 15 insertions(+), 6 deletions(-) diff --git a/Koha/SearchMappingManager.pm b/Koha/SearchMappingManager.pm index bc7e231704..77ddd0ba42 100644 --- a/Koha/SearchMappingManager.pm +++ b/Koha/SearchMappingManager.pm @@ -46,6 +46,7 @@ and their respective Koha::Objects in a correct manner. $search_field->get_column('facet'), $search_field->get_column('suggestible'), $search_field->get_column('sort'), + $search_field->get_column('filter'), $search_field->get_column('marc_type'), $search_field->get_column('marc_field'), ); @@ -79,6 +80,7 @@ sub get_search_mappings { 'search_marc_to_fields.suggestible', 'search_marc_to_fields.sort', 'search_marc_to_fields.search', + 'search_marc_to_fields.filter', 'search_marc_map.marc_type', 'search_marc_map.marc_field', ], @@ -87,6 +89,7 @@ sub get_search_mappings { 'suggestible', 'sort', 'search', + 'filter', 'marc_type', 'marc_field', ], @@ -120,7 +123,8 @@ sub flush { marc_field => '024a', facet => 1, suggestible => 1, - sort => 1}); + sort => 1, + filter => 'filter'}); =cut @@ -144,7 +148,8 @@ sub add_mapping { $p->{facet} = $params->{facet} if $params->{facet}; $p->{suggestible} = $params->{suggestible} if $params->{suggestible}; $p->{sort} = $params->{sort} if $params->{sort}; - $p->{search} = $params->{search} if $params->{search}; + $p->{search} = $params->{search} if $params->{search}; + $p->{filter} = $params->{filter} if $params->{filter}; Koha::Database->schema->resultset('SearchMarcToField')->update_or_create($p); } diff --git a/t/db_dependent/Koha/SearchEngine/ElasticSearch.t b/t/db_dependent/Koha/SearchEngine/ElasticSearch.t index f0d749f69c..22c9c6641f 100755 --- a/t/db_dependent/Koha/SearchEngine/ElasticSearch.t +++ b/t/db_dependent/Koha/SearchEngine/ElasticSearch.t @@ -60,7 +60,8 @@ subtest 'reset_elasticsearch_mappings() tests' => sub { marc_field => '024a', facet => 1, suggestible => 1, - sort => 1}); + sort => 1, + filter => 'punctuation'}); ok($rv, 'Given a mapping table with a custom search field'); eval { $rv = Koha::SearchEngine::Elasticsearch->reset_elasticsearch_mappings(); @@ -78,7 +79,7 @@ subtest 'reset_elasticsearch_mappings() tests' => sub { subtest 'get_search_mappings() tests' => sub { - plan tests => 13; + plan tests => 14; my ($mappings, $mapping); @@ -92,6 +93,7 @@ subtest 'get_search_mappings() tests' => sub { is($mapping->get_column('suggestible'), '0', 'And the search mapping "suggestible" matches'); is($mapping->get_column('sort'), '1', 'And the search mapping "sort" matches'); is($mapping->get_column('search'), '1', 'And the search mapping "search" matches'); + is($mapping->get_column('filter'), '', 'And the searc mapping "filter" matches'); is($mapping->get_column('marc_type'), 'marc21', 'And the search mapping "marc_type" matches'); is($mapping->get_column('marc_field'), '007_/0', 'And the search mapping "marc_field" matches'); @@ -117,7 +119,8 @@ subtest 'add_mapping() tests' => sub { marc_field => '024a', facet => 1, suggestible => 1, - sort => 1}); + sort => 1, + filter => 'punctuation'}); $rv = Koha::SearchMappingManager::add_mapping({name => 'ln-test', label => 'original language', type => '', @@ -126,7 +129,8 @@ subtest 'add_mapping() tests' => sub { marc_field => '024a', facet => 1, suggestible => 1, - sort => 1}); + sort => 1, + filter => 'punctuation'}); ok(1, "When the same search mapping is added twice"); $mappings = Koha::SearchMappingManager::get_search_mappings({index_name => 'biblios', name => 'ln-test'}); -- 2.34.1