[Bug 44191] New: Record matching ranks candidates by comparing scores as text, so a lower-scoring record can be chosen for overlay
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=44191 Bug ID: 44191 Summary: Record matching ranks candidates by comparing scores as text, so a lower-scoring record can be chosen for overlay Initiative type: --- Sponsorship --- status: Product: Koha Version: Main Hardware: All OS: All Status: NEW Severity: major Priority: P5 - low Component: MARC Bibliographic record staging/import Assignee: koha-bugs@lists.koha-community.org Reporter: babarjunaid1122@gmail.com QA Contact: testopia@bugs.koha-community.org Target Milestone: --- C4::Matcher::get_matches sorts the candidate records with a string comparison: @results = sort { $b->{'score'} cmp $a->{'score'} or $b->{'record_id'} cmp $a->{'record_id'} } @results; Scores are numbers, so as text "900" sorts above "1000" and "500" above "1000". The import keeps the first max_matches results (1 when staging), so the record that best matches the incoming one can be dropped and a weaker match chosen. Committing the batch with "Replace existing record" then overlays the wrong record. Example with a rule that has two matchpoints, ISBN (score 1000) and title (score 500), threshold 500: an incoming record whose ISBN matches record A and whose title matches a different record B. A scores 1000 and B 500, but B is reported as the match and overlaid. The same applies to authority matching, and the record_id tie-break is also a string comparison ("99" above "100"). To reproduce: 1. Administration > Record matching rules: a biblio rule with matchpoint 1 = index isbn, tag 020 $a, score 1000, and matchpoint 2 = index title, tag 245 $a, score 500; threshold 500. 2. Take two catalogue records A and B with different titles; A has an ISBN. 3. Stage a MARC file with one record that has A's ISBN and B's title, using that rule. 4. Manage staged records: the match shown is B (score 500), not A (score 1000). Or: prove t/db_dependent/Matcher.t with the subtest in the attached patch. Reproduced on main (6ff8078). -- You are receiving this mail because: You are watching all bug changes. You are the assignee for the bug.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=44191 --- Comment #1 from babar junaid <babarjunaid1122@gmail.com> --- Created attachment 212180 --> https://bugs.koha-community.org/bugzilla3/attachment.cgi?id=212180&action=edit Bug 44191: Sort match candidates by numeric score Bug 44191: Sort match candidates by numeric score C4::Matcher::get_matches sorted the candidates with cmp, so as text a score of 900 ranked above 1000 and a weaker match could be kept while the best one was dropped (staging keeps only the first). The record_id tie-break had the same problem. Both now compare numerically. Test plan: 1. prove t/db_dependent/Matcher.t The new subtest fails without the patch: the candidate scoring 900 is returned instead of the one scoring 1000. 2. Apply the patch, prove again: all pass. 3. Optional, in the staff interface: a biblio matching rule with isbn (020$a, score 1000) and title (245$a, score 500), threshold 500. Stage a record that has record A's ISBN and record B's title. Without the patch the staged record matches B; with it, A. Sponsored-by: Koha Solutions -- You are receiving this mail because: You are the assignee for the bug. You are watching all bug changes.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=44191 babar junaid <babarjunaid1122@gmail.com> changed: What |Removed |Added ---------------------------------------------------------------------------- Status|NEW |Needs Signoff Assignee|koha-bugs@lists.koha-commun |babarjunaid1122@gmail.com |ity.org | -- You are receiving this mail because: You are watching all bug changes. You are the assignee for the bug.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=44191 --- Comment #2 from babar junaid <babarjunaid1122@gmail.com> --- A correction to the steps in the description, from running them on main (6ff8078) with the sample data: Rule: isbn (020$a) score 1000 + title (245$a) score 500, threshold 500. Staged one record with the ISBN of one catalogue record and the title of another ("Miskatronic University Review"), with misc/stage_file.pl --match <rule id>. The title matchpoint finds many records (word search), all scoring 500, and staging keeps 10 candidates. Sorted as text, "500" ranks above "1000", so the one candidate scoring 1000 is not just ranked lower: it is cut from the list altogether. Without the patch (import_record_matches for the batch): 10 candidates, all score 500; the chosen one is biblio 90 (score 500). The ISBN match (score 1000) is not among them. With the patch: biblio 289 score 1000, chosen; then nine candidates with score 500. (The record the ISBN search returned is 289 on this instance's Zebra index, not the record I took the ISBN from; that is a search question, unrelated to this bug. The point is the 1000 candidate being dropped and a 500 candidate chosen.) So the description's "the match shown is B" is too specific: what you see is a 500-score candidate chosen and the 1000-score one missing. -- You are receiving this mail because: You are watching all bug changes.
participants (1)
-
bugzilla-daemon@bugs.koha-community.org