Bug 5555 - ISBN search returns bad results
Summary: ISBN search returns bad results
Status: CLOSED FIXED
Alias: None
Product: Koha
Classification: Unclassified
Component: Searching (show other bugs)
Version: rel_3_2
Hardware: All All
: P3 major
Assignee: Janusz Kaczmarek
QA Contact: Bugs List
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2010-12-30 09:23 UTC by Janusz Kaczmarek
Modified: 2012-10-25 23:09 UTC (History)
2 users (show)

See Also:
Change sponsored?: ---
Patch complexity: ---
Documentation contact:
Documentation submission:
Text to go in the release notes:
Version(s) released in:
Circulation function:


Attachments
Proposed patch (1.58 KB, patch)
2011-03-28 16:55 UTC, Janusz Kaczmarek
Details | Diff | Splinter Review

Note You need to log in before you can comment on or make changes to this bug.
Description Janusz Kaczmarek 2010-12-30 09:23:08 UTC
When making ISBN search (having chosen ISBN from the menu, NOT using ccl query) Koha generates fake results - instead of using nb (@attr 1=7) index it looks for given string anywhere in records.  This is, most probably, caused by following fragment of C4::Search::buildQuery:

                # ISBN,ISSN,Standard Number, don't need special treatment
                elsif ( $index eq 'nb' || $index eq 'ns' ) {
                    $indexes_set++;
                    (
                        $stemming,      $auto_truncation,
                        $weight_fields, $fuzzy_enabled,
                        $remove_stopwords
                    ) = ( 0, 0, 0, 0, 0 );

                }

Fast workaround could be as attached at the bottom, but maybe somebody would propose a more elegant solution.

Best regards,

Janusz


--- Search.pm   2010-12-30 10:41:23.000000000 +0200
+++ /usr/share/koha/lib/C4/Search.pm    2010-12-30 10:33:35.000000000 +0200
@@ -1125,6 +1129,7 @@
                 unless ( $indexes_set || !$index || $index =~ /(st-|phr|ext|wrdl)/ ) {
                     $struct_attr = ",wrdl";
                 }
+$indexes_set = 0 if ( $index eq 'nb' || $index eq 'ns' ); 
 
                 # Some helpful index variants
                 my $index_plus       = $index . $struct_attr . ':';
@@ -1307,7 +1312,7 @@
     # This is flawed , means we can't search anything with : in it
     # if user wants to do ccl or cql, start the query with that
 #    $query =~ s/:/=/g;
-    $query =~ s/(?<=(ti|au|pb|su|an|kw|mc)):/=/g;
+    $query =~ s/(?<=(ti|au|pb|su|an|kw|mc|nb|nc)):/=/g;
     $query =~ s/(?<=(wrdl)):/=/g;
     $query =~ s/(?<=(trn|phr)):/=/g;
     $limit =~ s/:/=/g;
Comment 1 Janusz Kaczmarek 2011-03-28 16:52:38 UTC
Without proposed correction when searching for ISBN / ISSN (nb / ns) -- both using query form and using ccl query -- an incorrect query is sent to the zebra server (there is no @attr 1=7 set -- cf. zebrasrv output).  As a result a bad result set is generated.  

This issue is particularly annoying if (for some reason) the ISSN is entered (also) with dashes and the query is just about a part of ISBN -- then as a result one gets all the records containing the string in question in every possible place, e.g. as a record id or barcode or number of pages etc.
Comment 2 Janusz Kaczmarek 2011-03-28 16:55:56 UTC
Created attachment 3471 [details] [review]
Proposed patch
Comment 3 MJ Ray (software.coop) 2011-04-02 11:42:01 UTC
This bug is mentioned in:
Bug 5555: Corrected search for ISBN / ISSN http://lists.koha-community.org/pipermail/koha-patches/2011-March/014284.html
Comment 4 Chris Cormack 2011-04-04 21:32:14 UTC
Hi Stephane

Is the signed off patch available somewhere, not attached here, and can't see it on the list.

Thanks
Comment 5 Chris Cormack 2011-04-06 03:31:16 UTC
No signed off patch
Comment 6 Stéphane Delaune 2011-04-06 07:34:43 UTC
the mail is send, excuse me for forgetting
Comment 7 Chris Cormack 2011-04-06 07:50:48 UTC
No problem Stephane, I appreciate all the hard work you are all doing

Pushed now, please test