From a4dfdb794de1856105c75a8812546771909210c8 Mon Sep 17 00:00:00 2001 From: =?utf8?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=utf8 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 Signed-off-by: Nick Clemens Signed-off-by: Jonathan Druart Signed-off-by: Kyle M Hall (cherry picked from commit cfe712367943da16e00ea0bee35b75d31d4f943c) Signed-off-by: Fridolin Somers --- 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 c8291c0ff0..8771c3057b 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 6f7c6429ab..ae1675ca4e 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 1a8aa93ab2..fdcab32c3d 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 8b935af155..36c75bfbc1 100755 --- a/opac/opac-detail.pl +++ b/opac/opac-detail.pl @@ -189,7 +189,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.39.5