Bug 11254

Summary: breeding search must normalize ISBN
Product: Koha Reporter: Fridolin Somers <fridolin.somers>
Component: ToolsAssignee: Fridolin Somers <fridolin.somers>
Status: CLOSED FIXED QA Contact: Testopia <testopia>
Severity: normal    
Priority: P5 - low CC: gmcharlt, kyle, mtompset
Version: Main   
Hardware: All   
OS: All   
Change sponsored?: --- Patch complexity: Trivial patch
Documentation contact: Documentation submission:
Text to go in the release notes:
Version(s) released in:
Circulation function:
Attachments: Bug 11254 - breeding search must normalize ISBN
MARC file of ISBN 978-0-12-345678-6
[SIGNED OFF] Bug 11254 - breeding search must normalize ISBN
Bug 11254 - breeding search must normalize ISBN

Description Fridolin Somers 2013-11-15 09:41:03 UTC
When importing records, the ISBN is normalized and stored into database (see C4::Breeding::ImportBreeding).
But when searching with ISBN into reservoir, it is not normalized (see C4::Breeding::BreedingSearch).
So search does not match.
Comment 1 Fridolin Somers 2013-11-15 09:55:29 UTC Comment hidden (obsolete)
Comment 2 Mark Tompsett 2014-01-12 03:38:09 UTC
This eyeballs well, but step-by-step instructions would really help.
Comment 3 Fridolin Somers 2014-01-13 07:42:12 UTC
(In reply to M. Tompsett from comment #2)
> This eyeballs well, but step-by-step instructions would really help.
There is a test plan into patch comment :

Subject: [PATCH] Bug 11254 - breeding search must normalize ISBN

When importing records, the ISBN is normalized and stored into database (see C4::Breeding::ImportBreeding).
But when searching with ISBN into reservoir, it is not normalized (see C4::Breeding::BreedingSearch).
So search does not match.

This patch adds the normalisation to breeding search.
Also replaces call private method _isbn_cleanup by GetNormalizedISBN, the correct public method.
Also allows the breeding search on ISBN with hyphens.

Test plan :
- Import a record with ISBN 13 with hyphens. ie 978-2-8153-0357-6
- Go to cataloguing : cataloguing/addbooks.pl
- Enter ISBN 13 with hyphens. ie 978-2-8153-0357-6
=> the imported record is found
- Enter ISBN 13 without hyphens. ie 9782815303576
=> the imported record is found
- Enter normalized ISBN. ie 2815303574
=> the imported record is found
Comment 4 Mark Tompsett 2014-01-16 03:27:08 UTC
Created attachment 24443 [details]
MARC file of ISBN 978-0-12-345678-6

Sample data file that I used for testing.
https://www.forewordreviews.com/reviews/the-little-book-of-string-theory/
Comment 5 Mark Tompsett 2014-01-16 03:48:12 UTC
I reset my data to several months ago, to make sure I didn't have the sample record I have attached.

I did a staff client update.

I imported the record, and added an item.

I triggered a reindex:
$ ./misc/migration_tools/rebuild_zebra.pl -b -a -z -v

I went home, and clicked Cataloging to do a Cataloging Search.

I searched for 9780691142890, and it didn't come up, except in the reservoir.
I searched for 978-0-691-14289-0, and it came up in both the catalog and the reservoir.

I went to the biblio record, and edited the record to not have hyphens in the ISBN (020$a).

I triggered a reindex:
$ ./misc/migration_tools/rebuild_zebra.pl -b -a -z -v

I went home, and clicked Cataloging to do a Cataloging Search.

I searched for 9780691142890, and it came up in both the catalog and the reservoir.
I searched for 978-0-691-14289-0, and it didn't come up, except in the reservoir.

Shouldn't it be coming up for both the reservoir and the catalog regardless of hypens?
Comment 6 Fridolin Somers 2014-01-17 08:27:33 UTC
(In reply to M. Tompsett from comment #5)
> Shouldn't it be coming up for both the reservoir and the catalog regardless
> of hypens?
This behavior is enabled in catalog search by using UCI in Zebra indexation.

But this patch modifies a behavior only for breeding/reservoir search, which uses SQL query, not the search engine.
Comment 7 Mark Tompsett 2014-01-17 16:31:43 UTC Comment hidden (obsolete)
Comment 8 Mark Tompsett 2014-01-17 16:34:17 UTC
Vast improvement on reservoir searches by ISBN!
Comment 9 Kyle M Hall (khall) 2014-01-17 17:38:05 UTC
Created attachment 24527 [details] [review]
Bug 11254 - breeding search must normalize ISBN

When importing records, the ISBN is normalized and stored
into database (see C4::Breeding::ImportBreeding).  But when
searching with ISBN into reservoir, it is not normalized
(see C4::Breeding::BreedingSearch).  So search does not match.

This patch adds the normalisation to breeding search.  Also
replaces call private method _isbn_cleanup by GetNormalizedISBN,
the correct public method.  Also allows the breeding search
on ISBN with hyphens.

This is intended to fix only reservoir searches.

Revised Test plan
-----------------
 1) Back up DB
 2) Save copy of attached example somewhere findable
 2) Home -> Tools -> Stage MARC records for import
 3) Click Browse and select the example MARC file
 4) Click Upload file
 5) Tweak as desired then click Stage for import
 6) Click Manage staged records
 7) Click Import this batch into the catalog
 8) Home -> Cataloging
 9) In the Cataloging search text box type 978-0-691-14289-0 and
     click Submit
    -- ISBN13 with hypens not found in reservoir
10) In the Cataloging search text box type 9780691142890 and
     click Submit
    -- ISBN13 without hypens not found in reservoir
11) In the Cataloging search text box type 0-691-14289-0 and
     click Submit
    -- ISBN10 with hypens not found in reservoir
12) In the Cataloging search text box type 0691142890 and
     click Submit
    -- ISBN10 without hypens found in reservoir
13) Apply patch
14) Repeat steps 9-12, this time it is always found! :)

Signed-off-by: Mark Tompsett <mtompset@hotmail.com>
Signed-off-by: Kyle M Hall <kyle@bywatersolutions.com>
Comment 10 Galen Charlton 2014-04-19 21:52:06 UTC
Pushed to master.  Thanks, Fridolin!
Comment 11 Fridolin Somers 2014-08-13 07:45:13 UTC
Pushed to 3.14.x, will be in 3.14.10
Comment 12 Kyle M Hall (khall) 2014-08-13 18:31:05 UTC
Picked for 3.12.15!