From 72a039670b5d414f1003f7713cb6585b8a1d79c7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Joonas=20Kylm=C3=A4l=C3=A4?= Date: Fri, 4 Jun 2021 14:06:53 +0300 Subject: [PATCH] Bug 28513: Fix analytics search links so they don't match unrelated biblios MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit At least when using Searchengine=Elasticsearch what happened was that without () parenthese included the search for Host-item field was done only to the first token, the subsequent ones matched any fields. Adding the parentheses restrict the search to Host-item search field only. To test: 1) Set Searchengine = elasticsearch 2) Make a biblio with 245a = "biológica paranaense." and 773a = "Acta" 3) Go to a biblio with 245a = "Acta biológica paranaense" (in kohadevbox or create one if you need). 4) Notice that the "Acta biológica paranaense" biblio's detail page link "Show analytics" takes to the "biológica paranaense" incorrectly just because the 773a has "Acta" and the words "biológica" and "paranaense" appear elsewhere in the biblio. 5) Apply patch and notice the link is now not created at all Signed-off-by: David Nind Signed-off-by: David Nind --- catalogue/detail.pl | 2 +- .../intranet-tmpl/prog/en/xslt/MARC21slim2intranetDetail.xsl | 2 +- koha-tmpl/opac-tmpl/bootstrap/en/xslt/MARC21slim2OPACDetail.xsl | 2 +- opac/opac-detail.pl | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-) diff --git a/catalogue/detail.pl b/catalogue/detail.pl index 14b4f1794b..0ba37e7253 100755 --- a/catalogue/detail.pl +++ b/catalogue/detail.pl @@ -132,7 +132,7 @@ if ( $xslfile ) { my $query = ( C4::Context->preference('UseControlNumber') and $record->field('001') ) ? 'rcn:'. $record->field('001')->data . ' AND (bib-level:a OR bib-level:b)' - : "Host-item:$cleaned_title"; + : "Host-item:($cleaned_title)"; my ( $err, $result, $count ) = $searcher->simple_search_compat( $query, 0, 0 ); warn "Warning from simple_search_compat: $err" diff --git a/koha-tmpl/intranet-tmpl/prog/en/xslt/MARC21slim2intranetDetail.xsl b/koha-tmpl/intranet-tmpl/prog/en/xslt/MARC21slim2intranetDetail.xsl index 079f44a14a..196d5857ee 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/xslt/MARC21slim2intranetDetail.xsl +++ b/koha-tmpl/intranet-tmpl/prog/en/xslt/MARC21slim2intranetDetail.xsl @@ -222,7 +222,7 @@ /cgi-bin/koha/catalogue/search.pl?q=rcn:+AND+(bib-level:a+OR+bib-level:b) - /cgi-bin/koha/catalogue/search.pl?q=Host-item: + /cgi-bin/koha/catalogue/search.pl?q=Host-item:() Show analytics diff --git a/koha-tmpl/opac-tmpl/bootstrap/en/xslt/MARC21slim2OPACDetail.xsl b/koha-tmpl/opac-tmpl/bootstrap/en/xslt/MARC21slim2OPACDetail.xsl index 4341bf0950..0110d22215 100644 --- a/koha-tmpl/opac-tmpl/bootstrap/en/xslt/MARC21slim2OPACDetail.xsl +++ b/koha-tmpl/opac-tmpl/bootstrap/en/xslt/MARC21slim2OPACDetail.xsl @@ -257,7 +257,7 @@ /cgi-bin/koha/opac-search.pl?q=rcn:+AND+(bib-level:a+OR+bib-level:b) - /cgi-bin/koha/opac-search.pl?q=Host-item: + /cgi-bin/koha/opac-search.pl?q=Host-item:() Show analytics diff --git a/opac/opac-detail.pl b/opac/opac-detail.pl index 6173b72862..1b7f98f64d 100755 --- a/opac/opac-detail.pl +++ b/opac/opac-detail.pl @@ -188,7 +188,7 @@ if ( $xslfile ) { my $query = ( C4::Context->preference('UseControlNumber') and $record->field('001') ) ? 'rcn:'. $record->field('001')->data . ' AND (bib-level:a OR bib-level:b)' - : "Host-item:$cleaned_title"; + : "Host-item:($cleaned_title)"; my ( $err, $result, $count ) = $searcher->simple_search_compat( $query, 0, 0 ); warn "Warning from simple_search_compat: $err" -- 2.20.1