Bug 25278: add clear_search_fields_cache method
Signed-off-by: Jonathan Druart <jonathan.druart@bugs.koha-community.org> Signed-off-by: Martin Renvoize <martin.renvoize@ptfs-europe.com> Signed-off-by: Joy Nelson <joy@bywatersolutions.com>
This commit is contained in:
parent
1ea9aac108
commit
c38eea3da3
|
|
@ -331,11 +331,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?
|
||||
}
|
||||
|
|
@ -1233,6 +1229,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__
|
||||
|
|
|
|||
|
|
@ -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->();
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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 });
|
||||
|
|
|
|||
|
|
@ -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();
|
||||
|
|
|
|||
Loading…
Reference in New Issue