Bugzilla – Attachment 87972 Details for
Bug 22474
Authority and biblio field mapping improperly shared
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 22474: Clone field config before adding fields to it
Bug-22474-Clone-field-config-before-adding-fields-.patch (text/plain), 4.64 KB, created by
Chris Cormack
on 2019-04-15 00:23:12 UTC
(
hide
)
Description:
Bug 22474: Clone field config before adding fields to it
Filename:
MIME Type:
Creator:
Chris Cormack
Created:
2019-04-15 00:23:12 UTC
Size:
4.64 KB
patch
obsolete
>From a2f2e1337adeabaf78e75505b3cfd865ba7d3f82 Mon Sep 17 00:00:00 2001 >From: Ere Maijala <ere.maijala@helsinki.fi> >Date: Thu, 7 Mar 2019 16:35:30 +0200 >Subject: [PATCH] Bug 22474: Clone field config before adding fields to it >MIME-Version: 1.0 >Content-Type: text/plain; charset=UTF-8 >Content-Transfer-Encoding: 8bit > >Test plain: > >1. Reindex both authorities and biblios with the -d flag to recreate the index, e.g. "perl misc/search_tools/rebuild_elastic_search.pl -v -d" >2. Check that authorities only contains authority-specific fields in Elasticsearch e.g. by fetching http://localhost:9200/koha_dev_authorities/_mappings >3. Reindex both without the -d flag and verify it works, e.g. "perl misc/search_tools/rebuild_elastic_search.pl -v" > >Signed-off-by: Björn Nylén <bjorn.nylen@ub.lu.se> >Signed-off-by: Chris Cormack <chris@bigballofwax.co.nz> >--- > C4/Installer/PerlDependencies.pm | 2 +- > Koha/SearchEngine/Elasticsearch.pm | 21 ++++++++++++--------- > 2 files changed, 13 insertions(+), 10 deletions(-) > >diff --git a/C4/Installer/PerlDependencies.pm b/C4/Installer/PerlDependencies.pm >index fc5e99e0ca..2225463349 100644 >--- a/C4/Installer/PerlDependencies.pm >+++ b/C4/Installer/PerlDependencies.pm >@@ -889,7 +889,7 @@ our $PERL_DEPS = { > min_ver => '0.17' > }, > 'Clone' => { >- usage => 'ILL, Test suite', >+ usage => 'ILL, Test suite, Elasticsearch integration', > required => '1', > min_ver => '0.37', > }, >diff --git a/Koha/SearchEngine/Elasticsearch.pm b/Koha/SearchEngine/Elasticsearch.pm >index 3855ce4df5..92453488da 100644 >--- a/Koha/SearchEngine/Elasticsearch.pm >+++ b/Koha/SearchEngine/Elasticsearch.pm >@@ -27,6 +27,7 @@ use Koha::SearchFields; > use Koha::SearchMarcMaps; > > use Carp; >+use Clone qw(clone); > use JSON; > use Modern::Perl; > use Readonly; >@@ -192,13 +193,15 @@ sub get_elasticsearch_mappings { > > if (!defined $all_mappings{$self->index}) { > $sort_fields{$self->index} = {}; >+ # Clone the general mapping to break ties with the original hash > my $mappings = { >- data => scalar _get_elasticsearch_mapping('general', '') >+ data => clone(_get_elasticsearch_field_config('general', '')) > }; > my $marcflavour = lc C4::Context->preference('marcflavour'); > $self->_foreach_mapping( > sub { > my ( $name, $type, $facet, $suggestible, $sort, $marc_type ) = @_; >+ > return if $marc_type ne $marcflavour; > # TODO if this gets any sort of complexity to it, it should > # be broken out into its own function. >@@ -214,19 +217,19 @@ sub get_elasticsearch_mappings { > $es_type = 'stdno'; > } > >- $mappings->{data}{properties}{$name} = _get_elasticsearch_mapping('search', $es_type); >+ $mappings->{data}{properties}{$name} = _get_elasticsearch_field_config('search', $es_type); > > if ($facet) { >- $mappings->{data}{properties}{ $name . '__facet' } = _get_elasticsearch_mapping('facet', $es_type); >+ $mappings->{data}{properties}{ $name . '__facet' } = _get_elasticsearch_field_config('facet', $es_type); > } > if ($suggestible) { >- $mappings->{data}{properties}{ $name . '__suggestion' } = _get_elasticsearch_mapping('suggestible', $es_type); >+ $mappings->{data}{properties}{ $name . '__suggestion' } = _get_elasticsearch_field_config('suggestible', $es_type); > } > # Sort is a bit special as it can be true, false, undef. > # We care about "true" or "undef", > # "undef" means to do the default thing, which is make it sortable. > if (!defined $sort || $sort) { >- $mappings->{data}{properties}{ $name . '__sort' } = _get_elasticsearch_mapping('sort', $es_type); >+ $mappings->{data}{properties}{ $name . '__sort' } = _get_elasticsearch_field_config('sort', $es_type); > $sort_fields{$self->index}{$name} = 1; > } > } >@@ -238,15 +241,15 @@ sub get_elasticsearch_mappings { > return $all_mappings{$self->index}; > } > >-=head2 _get_elasticsearch_mapping >+=head2 _get_elasticsearch_field_config > >-Get the Elasticsearch mappings for the given purpose and data type. >+Get the Elasticsearch field config for the given purpose and data type. > >-$mapping = _get_elasticsearch_mapping('search', 'text'); >+$mapping = _get_elasticsearch_field_config('search', 'text'); > > =cut > >-sub _get_elasticsearch_mapping { >+sub _get_elasticsearch_field_config { > > my ( $purpose, $type ) = @_; > >-- >2.11.0
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Diff
|
Splinter Review
Attachments on
bug 22474
:
86278
|
86664
| 87972