Bugzilla – Attachment 104947 Details for
Bug 25278
Search fields cache must be separate for different indexes under Elasticsearch
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 25278: add clear_search_fields_cache method
Bug-25278-add-clearsearchfieldscache-method.patch (text/plain), 5.07 KB, created by
Jonathan Druart
on 2020-05-15 13:18:35 UTC
(
hide
)
Description:
Bug 25278: add clear_search_fields_cache method
Filename:
MIME Type:
Creator:
Jonathan Druart
Created:
2020-05-15 13:18:35 UTC
Size:
5.07 KB
patch
obsolete
>From d125af2db0891658d450fd242f641338fda86f23 Mon Sep 17 00:00:00 2001 >From: Nick Clemens <nick@bywatersolutions.com> >Date: Fri, 15 May 2020 11:46:07 +0000 >Subject: [PATCH] Bug 25278: add clear_search_fields_cache method > >Signed-off-by: Jonathan Druart <jonathan.druart@bugs.koha-community.org> >--- > Koha/SearchEngine/Elasticsearch.pm | 24 +++++++++++++++---- > admin/searchengine/elasticsearch/mappings.pl | 6 +---- > .../SearchEngine/Elasticsearch/QueryBuilder.t | 10 +------- > .../Koha/SearchEngine/Elasticsearch/Reset.t | 6 +---- > 4 files changed, 22 insertions(+), 24 deletions(-) > >diff --git a/Koha/SearchEngine/Elasticsearch.pm b/Koha/SearchEngine/Elasticsearch.pm >index 7afb9aab54..a43b864145 100644 >--- a/Koha/SearchEngine/Elasticsearch.pm >+++ b/Koha/SearchEngine/Elasticsearch.pm >@@ -382,11 +382,7 @@ sub reset_elasticsearch_mappings { > } > } > >- my $cache = Koha::Caches->get_instance(); >- $cache->clear_from_cache('elasticsearch_search_fields_staff_client_biblios'); >- $cache->clear_from_cache('elasticsearch_search_fields_opac_biblios'); >- $cache->clear_from_cache('elasticsearch_search_fields_staff_client_authorities'); >- $cache->clear_from_cache('elasticsearch_search_fields_opac_authorities'); >+ $self->clear_search_fields_cache(); > > # FIXME return the mappings? > } >@@ -1287,6 +1283,24 @@ sub get_facetable_fields { > return ( @faceted_fields, @not_faceted_fields ); > } > >+=head2 clear_search_fields_cache >+ >+Koha::SearchEngine::Elasticsearch->clear_search_fields_cache(); >+ >+Clear cached values for ES search fields >+ >+=cut >+ >+sub clear_search_fields_cache { >+ >+ my $cache = Koha::Caches->get_instance(); >+ $cache->clear_from_cache('elasticsearch_search_fields_staff_client_biblios'); >+ $cache->clear_from_cache('elasticsearch_search_fields_opac_biblios'); >+ $cache->clear_from_cache('elasticsearch_search_fields_staff_client_authorities'); >+ $cache->clear_from_cache('elasticsearch_search_fields_opac_authorities'); >+ >+} >+ > 1; > > __END__ >diff --git a/admin/searchengine/elasticsearch/mappings.pl b/admin/searchengine/elasticsearch/mappings.pl >index 5212c2a5cb..57a9656f9c 100755 >--- a/admin/searchengine/elasticsearch/mappings.pl >+++ b/admin/searchengine/elasticsearch/mappings.pl >@@ -165,11 +165,7 @@ if ( $op eq 'edit' ) { > push @messages, { type => 'message', code => 'success_on_update' }; > $schema->storage->txn_commit; > >- my $cache = Koha::Caches->get_instance(); >- $cache->clear_from_cache('elasticsearch_search_fields_staff_client_biblios'); >- $cache->clear_from_cache('elasticsearch_search_fields_opac_biblios'); >- $cache->clear_from_cache('elasticsearch_search_fields_staff_client_authorities'); >- $cache->clear_from_cache('elasticsearch_search_fields_opac_authorities'); >+ Koha::SearchEngine::Elasticsearch->clear_search_fields_cache(); > > $update_mappings->(); > } >diff --git a/t/db_dependent/Koha/SearchEngine/Elasticsearch/QueryBuilder.t b/t/db_dependent/Koha/SearchEngine/Elasticsearch/QueryBuilder.t >index a3ff646bad..bf6d77d70e 100644 >--- a/t/db_dependent/Koha/SearchEngine/Elasticsearch/QueryBuilder.t >+++ b/t/db_dependent/Koha/SearchEngine/Elasticsearch/QueryBuilder.t >@@ -101,14 +101,6 @@ $se->mock( 'get_elasticsearch_mappings', sub { > return $all_mappings{$self->index}; > }); > >-my $cache = Koha::Caches->get_instance(); >-my $clear_search_fields_cache = sub { >- $cache->clear_from_cache('elasticsearch_search_fields_staff_client_biblios'); >- $cache->clear_from_cache('elasticsearch_search_fields_opac_biblios'); >- $cache->clear_from_cache('elasticsearch_search_fields_staff_client_authorities'); >- $cache->clear_from_cache('elasticsearch_search_fields_opac_authorities'); >-}; >- > subtest 'build_authorities_query_compat() tests' => sub { > > plan tests => 57; >@@ -635,7 +627,7 @@ subtest 'build_query with weighted fields tests' => sub { > $search_field->update({ weight => 25.0 }); > $search_field = Koha::SearchFields->find({ name => 'subject' }); > $search_field->update({ weight => 15.5 }); >- $clear_search_fields_cache->(); >+ Koha::SearchEngine::Elasticsearch->clear_search_fields_cache(); > > my ( undef, $query ) = $qb->build_query_compat( undef, ['title:"donald duck"'], undef, undef, > undef, undef, undef, { weighted_fields => 1 }); >diff --git a/t/db_dependent/Koha/SearchEngine/Elasticsearch/Reset.t b/t/db_dependent/Koha/SearchEngine/Elasticsearch/Reset.t >index 0c07a260d6..e57ee16596 100644 >--- a/t/db_dependent/Koha/SearchEngine/Elasticsearch/Reset.t >+++ b/t/db_dependent/Koha/SearchEngine/Elasticsearch/Reset.t >@@ -72,8 +72,4 @@ is($title_sf->weight, '20.00', 'Title search field is weighted with 20'); > > $schema->storage->txn_rollback; > >-$cache = Koha::Caches->get_instance(); >-$cache->clear_from_cache('elasticsearch_search_fields_staff_client_biblios'); >-$cache->clear_from_cache('elasticsearch_search_fields_opac_biblios'); >-$cache->clear_from_cache('elasticsearch_search_fields_staff_client_authorities'); >-$cache->clear_from_cache('elasticsearch_search_fields_opac_authorities'); >+Koha::SearchEngine::Elasticsearch->clear_search_fields_cache(); >-- >2.20.1
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 25278
:
103697
|
103699
|
103700
|
103793
|
104896
|
104897
|
104898
|
104939
|
104944
|
104945
|
104946
| 104947