Bugzilla – Attachment 111212 Details for
Bug 26608
Authorities: linked biblios is inconsistent using elasticsearch and QueryAutoTruncate
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 26608: Elasticsearch - add exact (ext) field type and use it for linked biblios
Bug-26608-Elasticsearch---add-exact-ext-field-type.patch (text/plain), 3.87 KB, created by
Alex Arnaud
on 2020-10-05 09:04:07 UTC
(
hide
)
Description:
Bug 26608: Elasticsearch - add exact (ext) field type and use it for linked biblios
Filename:
MIME Type:
Creator:
Alex Arnaud
Created:
2020-10-05 09:04:07 UTC
Size:
3.87 KB
patch
obsolete
>From b8140a78464cae6dff9561fed8330bf5ce469d8b Mon Sep 17 00:00:00 2001 >From: Alex Arnaud <alex.arnaud@biblibre.com> >Date: Mon, 5 Oct 2020 09:03:18 +0000 >Subject: [PATCH] Bug 26608: Elasticsearch - add exact (ext) field type and use > it for linked biblios > >Test plan: > - Enable Elasticsearch engine, > - Enable QueryAutoTruncate systempreference, > - Show the detail od authority #1 > (cgi-bin/koha/authorities/detail.pl?authid=1) > - note the inconsistent count of linked biblio (and so the list), > - Apply this patch, > - Restart all, > - repeat previous step, > - Count and list of linked biblios should be ok. >--- > Koha/Authorities.pm | 8 +++++++- > Koha/SearchEngine/Elasticsearch/QueryBuilder.pm | 4 ++-- > koha-tmpl/intranet-tmpl/prog/en/modules/authorities/detail.tt | 2 +- > 3 files changed, 10 insertions(+), 4 deletions(-) > >diff --git a/Koha/Authorities.pm b/Koha/Authorities.pm >index 0145eb3..ebc28b3 100644 >--- a/Koha/Authorities.pm >+++ b/Koha/Authorities.pm >@@ -25,6 +25,9 @@ use Koha::Database; > > use Koha::Authority; > >+use Koha::SearchEngine::Search; >+use Koha::SearchEngine::QueryBuilder; >+ > use base qw(Koha::Objects); > > =head1 NAME >@@ -51,8 +54,11 @@ sub get_usage_count { > my ( $class, $params ) = @_; > my $authid = $params->{authid} || return; > >+ my $builder = Koha::SearchEngine::QueryBuilder->new({index => $Koha::SearchEngine::BIBLIOS_INDEX}); > my $searcher = Koha::SearchEngine::Search->new({ index => $Koha::SearchEngine::BIBLIOS_INDEX }); >- my ( $err, $result, $count ) = $searcher->simple_search_compat( 'an:' . $authid, 0, 0 ); >+ >+ my ($builderror, $query)= $builder->build_query_compat( undef, [$authid], ['an,ext'], [], []); >+ my ( $err, $result, $count ) = $searcher->simple_search_compat( $query, 0, 0 ); > if( $err ) { > warn "Error: $err from search for " . $authid; > return; >diff --git a/Koha/SearchEngine/Elasticsearch/QueryBuilder.pm b/Koha/SearchEngine/Elasticsearch/QueryBuilder.pm >index edd0b1b..29da4d2 100644 >--- a/Koha/SearchEngine/Elasticsearch/QueryBuilder.pm >+++ b/Koha/SearchEngine/Elasticsearch/QueryBuilder.pm >@@ -187,7 +187,7 @@ sub build_query_compat { > while ( my ( $oand, $otor, $index ) = $ea->() ) { > next if ( !defined($oand) || $oand eq '' ); > $oand = $self->_clean_search_term($oand); >- $oand = $self->_truncate_terms($oand) if ($truncate); >+ $oand = $self->_truncate_terms($oand) if ($truncate && $index->{type} ne 'ext'); > push @search_params, { > operand => $oand, # the search terms > operator => defined($otor) ? uc $otor : undef, # AND and so on >@@ -712,7 +712,7 @@ sub _convert_index_fields { > my ( $self, @indexes ) = @_; > > my %index_type_convert = >- ( __default => undef, phr => 'phrase', rtrn => 'right-truncate', 'st-year' => 'st-year' ); >+ ( __default => undef, phr => 'phrase', rtrn => 'right-truncate', 'st-year' => 'st-year', 'ext' => 'ext' ); > > # Convert according to our table, drop anything that doesn't convert. > # If a field starts with mc- we save it as it's used (and removed) later >diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/authorities/detail.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/authorities/detail.tt >index 2afd642..2713bbd 100644 >--- a/koha-tmpl/intranet-tmpl/prog/en/modules/authorities/detail.tt >+++ b/koha-tmpl/intranet-tmpl/prog/en/modules/authorities/detail.tt >@@ -44,7 +44,7 @@ > > <div id="action"> > [% IF count %] >- Used in <a href="/cgi-bin/koha/catalogue/search.pl?type=intranet&op=do_search&q=an=[% authid | uri %]">[% count | html %] record(s)</a> >+ Used in <a href="/cgi-bin/koha/catalogue/search.pl?type=intranet&op=do_search&idx=an,ext&q=[% authid | uri %]">[% count | html %] record(s)</a> > [% ELSE %] > This authority is not used in any records. > [% END %] >-- >2.7.4
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 26608
: 111212