From 036f2a50e11dab97ef8509f2f585c4cc407ea728 Mon Sep 17 00:00:00 2001 From: Galen Charlton Date: Mon, 5 May 2014 19:31:00 +0000 Subject: [PATCH] Bug 10500: (follow-up) disable AggressiveMatchOnISBN if UseQueryParser is on The original patch did not correctly construction ISBN phrase searches when QP is on. Unfortunately, when attempting to fix that, I discovered that there's a deep bug in QP that makes it generate incorrect search queries when combining more than two atoms in with the || operator. Consequently, until that can be fixed, this patch ensures that if UseQueryParser is on, AggressiveMatchOnISBN has no effect. To state it anther way, AggressiveMatchOnISBN works only when QP is not in use. Signed-off-by: Galen Charlton --- C4/Matcher.pm | 11 ++++++++--- .../en/modules/admin/preferences/cataloguing.pref | 2 +- 2 files changed, 9 insertions(+), 4 deletions(-) diff --git a/C4/Matcher.pm b/C4/Matcher.pm index 25536c8ce9..8caab0a39c 100644 --- a/C4/Matcher.pm +++ b/C4/Matcher.pm @@ -633,9 +633,14 @@ sub get_matches { next if scalar(@source_keys) == 0; + # FIXME - because of a bug in QueryParser, an expression ofthe + # format 'isbn:"isbn1" || isbn:"isbn2" || isbn"isbn3"...' + # does not get parsed correctly, so we will not + # do AggressiveMatchOnISBN if UseQueryParser is on @source_keys = C4::Koha::GetVariationsOfISBNs(@source_keys) if ( $matchpoint->{index} =~ /^isbn$/i - && C4::Context->preference('AggressiveMatchOnISBN') ); + && C4::Context->preference('AggressiveMatchOnISBN') ) + && !C4::Context->preference('UseQueryParser'); # build query my $query; @@ -643,13 +648,13 @@ sub get_matches { my $searchresults; my $total_hits; if ( $self->{'record_type'} eq 'biblio' ) { - my $phr = C4::Context->preference('AggressiveMatchOnISBN') ? ',phr' : q{}; if ($QParser) { $query = join( " || ", - map { "$matchpoint->{'index'}$phr:$_" } @source_keys ); + map { "$matchpoint->{'index'}:$_" } @source_keys ); } else { + my $phr = C4::Context->preference('AggressiveMatchOnISBN') ? ',phr' : q{}; $query = join( " or ", map { "$matchpoint->{'index'}$phr=$_" } @source_keys ); } diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/admin/preferences/cataloguing.pref b/koha-tmpl/intranet-tmpl/prog/en/modules/admin/preferences/cataloguing.pref index a52180f799..1b8cce5ef8 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/modules/admin/preferences/cataloguing.pref +++ b/koha-tmpl/intranet-tmpl/prog/en/modules/admin/preferences/cataloguing.pref @@ -198,4 +198,4 @@ Cataloging: choices: yes: "do" no: "don't" - - attempt to match aggressively by trying all variations of the ISBNs in the imported record as a phrase in the ISBN fields of already cataloged records. + - attempt to match aggressively by trying all variations of the ISBNs in the imported record as a phrase in the ISBN fields of already cataloged records. Note that this preference has no effect if UseQueryParser is on. -- 2.39.5