Bugzilla – Attachment 144605 Details for
Bug 20596
Authority record matching rule causes staging failure when MARC record contains multiple tag values for a match point
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 20596: Join authority queries together with OR
Bug-20596-Join-authority-queries-together-with-OR.patch (text/plain), 3.43 KB, created by
Martin Renvoize (ashimema)
on 2022-12-15 08:18:58 UTC
(
hide
)
Description:
Bug 20596: Join authority queries together with OR
Filename:
MIME Type:
Creator:
Martin Renvoize (ashimema)
Created:
2022-12-15 08:18:58 UTC
Size:
3.43 KB
patch
obsolete
>From 50e78f6f39f2533ce61b6a2ac7089c05ff3cc452 Mon Sep 17 00:00:00 2001 >From: David Cook <dcook@prosentient.com.au> >Date: Wed, 14 Dec 2022 04:58:41 +0000 >Subject: [PATCH] Bug 20596: Join authority queries together with OR > >This patch joins authority queries together with OR like Elasticsearch. > >To the best of the author's knowledge, this code only gets triggered >when using record matching rules, but there may be other situations >where it's used. > >Authority search in cataloguing plugins use a different path, and >authority search in authority home doesn't allow multiple queries, >so they'll never trigger this OR joining of queries. > >Test plan: >0. Apply patch and koha-plack --restart kohadev >1. Create a record matching rule with the following: >Matching rule code: NID >Description: NormdatenID >Match threshold: 100 >Record type: Authority record >Search index: Any >Score: 101 >Tag: 035 >Subfields: a >Offset: 0 >Length: 0 >Normalization rule: None > >Click "Remove this match check" > >2. Stage gnd.xml (from BZ 20596 attachments) >- Choose "MARCXML" for "Format" >- Choose "Authority" for "Record type" >- Choose "NID" for "Record matching rule" >- Click "Stage for import" >3. Note the job gets to "100% Finished" >(Before this patch, it would say "0% Failed") > >4. View the batch >5. Import the record >6. Repeat steps 2-4 and note that the record matching rule >worked > >7. Go to http://localhost:8081/cgi-bin/koha/authorities/authorities-home.pl >8. Search for "e" >9. Note that the search works > >10. Go to http://localhost:8081/cgi-bin/koha/cataloguing/addbiblio.pl?frameworkcode= >11. Click tab 6 >12. Click on the tag editor next to "a Personal Name" >13. Type "e" into each box and click "Search" >14. Note that the search works > >Signed-off-by: Jan Kissig <jan.kissig@th-wildau.de> >Signed-off-by: Fridolin Somers <fridolin.somers@biblibre.com> >--- > C4/AuthoritiesMarc.pm | 18 +++++++++++++++++- > 1 file changed, 17 insertions(+), 1 deletion(-) > >diff --git a/C4/AuthoritiesMarc.pm b/C4/AuthoritiesMarc.pm >index 863ca3d6104..10d43422c9e 100644 >--- a/C4/AuthoritiesMarc.pm >+++ b/C4/AuthoritiesMarc.pm >@@ -207,9 +207,25 @@ sub SearchAuthorities { > } > ##Add how many queries generated > if (defined $query && $query=~/\S+/){ >+ #NOTE: This code path is used by authority search in cataloguing plugins... >+ #FIXME: This does not quite work the way the author probably intended. >+ #It creates a ($query prefix) AND (query 1) AND (query 2) structure instead of >+ #($query prefix) AND (query 1 AND query 2) > $query= $and x $attr_cnt . $query . (defined $q2 ? $q2 : ''); > } else { >- $query= $q2; >+ #NOTE: This code path is used by authority search in authority home and record matching rules... >+ my $op_prefix = ''; >+ #NOTE: Without the following code, multiple queries will never be joined together >+ #with a Boolean operator. >+ if ($attr_cnt > 1){ >+ #NOTE: We always need 1 less operator than we have operands, >+ #so long as there is more than 1 operand >+ my $or_cnt = $attr_cnt - 1; >+ #NOTE: We hard-code OR here because that's what Elasticsearch does >+ $op_prefix = ' @or ' x $or_cnt; >+ #NOTE: This evaluates to a logical structure like (query 1) OR (query 2) OR (query 3) >+ } >+ $query= $op_prefix . $q2; > } > ## Adding order > #$query=' @or @attr 7=2 @attr 1=Heading 0 @or @attr 7=1 @attr 1=Heading 1'.$query if ($sortby eq "HeadingDsc"); >-- >2.39.0
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Diff
|
Splinter Review
Attachments on
bug 20596
:
74361
|
144550
|
144551
|
144561
|
144562
|
144590
|
144591
|
144598
|
144599
|
144600
| 144605 |
144606
|
144607