Bug 10500: (follow-up) disable AggressiveMatchOnISBN if UseQueryParser is on
authorGalen Charlton <gmc@esilibrary.com>
Mon, 5 May 2014 19:31:00 +0000 (19:31 +0000)
committerGalen Charlton <gmc@esilibrary.com>
Mon, 5 May 2014 19:31:00 +0000 (19:31 +0000)
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 <gmc@esilibrary.com>
C4/Matcher.pm
koha-tmpl/intranet-tmpl/prog/en/modules/admin/preferences/cataloguing.pref

index 25536c8..8caab0a 100644 (file)
@@ -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 );
             }
index a52180f..1b8cce5 100644 (file)
@@ -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.