Bug 31841 - Shelving location search in staff interface sometimes creates invalid Zebra query
Summary: Shelving location search in staff interface sometimes creates invalid Zebra q...
Status: CLOSED FIXED
Alias: None
Product: Koha
Classification: Unclassified
Component: Searching - Zebra (show other bugs)
Version: Main
Hardware: All All
: P5 - low normal
Assignee: David Cook
QA Contact:
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2022-10-17 03:30 UTC by David Cook
Modified: 2024-07-04 20:37 UTC (History)
3 users (show)

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


Attachments
Bug 31841: Use location,wrdl when searching Shelving location (1.90 KB, patch)
2022-10-17 03:49 UTC, David Cook
Details | Diff | Splinter Review
Bug 31841: Use location,wrdl when searching Shelving location (1.88 KB, patch)
2023-03-29 00:34 UTC, David Cook
Details | Diff | Splinter Review
Bug 31841: Use location,wrdl when searching Shelving location (1.95 KB, patch)
2023-03-29 08:06 UTC, Magnus Enger
Details | Diff | Splinter Review
Bug 31841: Use location,wrdl when searching Shelving location (2.00 KB, patch)
2023-03-29 13:38 UTC, Nick Clemens (kidclamp)
Details | Diff | Splinter Review

Note You need to log in before you can comment on or make changes to this bug.
Description David Cook 2022-10-17 03:30:31 UTC
If you choose "Shelving location" in the staff interface dropdown menu, it generates an invalid Zebra search.

Example:

14:21:54-17/10 zebrasrv(3) [request] Search biblios ERROR 114 1 1+0 RPN @attrset Bib-1 @or @or @attr 1=8013 @attr 4=1 @attr 6=3 @attr 9=32 @attr 2=102 WEB @attr 1=8013 @attr 4=1 @attr 9=26 @attr 2=102 WEB @a
ttr 1=8013 @attr 4=6 @attr 9=20 @attr 2=102 WEB

Here's what we actually want to create:

14:21:48-17/10 zebrasrv(2) [request] Search biblios OK 20892 1 1+0 RPN @attrset Bib-1 @attr 1=8013 @attr 4=6 @attr 2=102 WEB
Comment 1 David Cook 2022-10-17 03:34:42 UTC
Ok it's working in master although it doesn't set the index dropdowns correctly so I guess I can re-purpose this report...
Comment 2 David Cook 2022-10-17 03:39:20 UTC
Or maybe not... certain permutations of sysprefs don't work...
Comment 3 David Cook 2022-10-17 03:41:56 UTC
In Master:
1) Turn off QueryAutoTruncate
2) Go to http://localhost:8081/cgi-bin/koha/catalogue/search.pl?q=GEN&idx=location
3) Note "No results found"

The problem is that QueryWeightFields adds a "phr" qualifier which is a problem since "location" doesn't have a phrase index defined...:

(rk=( location,ext,r1=" GEN " or location,phr,r3=" GEN " or location,wrdl,r6=" GEN " or location,wrdl,fuzzy,r8=" GEN " or location,wrdl,rt,r9=""gen"? "))
Comment 4 David Cook 2022-10-17 03:49:14 UTC Comment hidden (obsolete)
Comment 5 Katrin Fischer 2022-11-19 20:22:58 UTC
Hi David, did you mean to sign-off here?
Comment 6 David Cook 2022-11-20 22:33:18 UTC
(In reply to Katrin Fischer from comment #5)
> Hi David, did you mean to sign-off here?

I'm not sure I understand the question? ﷐[U+1F605]﷑
Comment 7 Katrin Fischer 2022-11-20 22:41:32 UTC
(In reply to David Cook from comment #6)
> (In reply to Katrin Fischer from comment #5)
> > Hi David, did you mean to sign-off here?
> 
> I'm not sure I understand the question? ﷐[U+1F605]﷑

Sorry, I got confused :)
Comment 8 David Cook 2022-11-20 22:49:45 UTC
(In reply to Katrin Fischer from comment #7)
> Sorry, I got confused :)

No worries!

I'd love to someone to sign it off though heh.
Comment 9 Fridolin Somers 2022-12-22 06:53:22 UTC
> since "location" doesn't have a phrase index defined...
Why not add it to Zebra MARC21 configuration ?

Even if unlikely :
Imagine two locations "foo bar" and "bar foo", words list type search "wrdl" will match both.

This indexing can be useful for other cases.
Comment 10 David Cook 2022-12-22 22:38:55 UTC
(In reply to Fridolin Somers from comment #9)
> > since "location" doesn't have a phrase index defined...
> Why not add it to Zebra MARC21 configuration ?

I suppose I try to avoid Zebra config changes that require people to re-index but fair point!

> Even if unlikely :
> Imagine two locations "foo bar" and "bar foo", words list type search "wrdl"
> will match both.

True although I have wanted to limit authorized value codes for a while so that they can only be alphanumeric and have no spaces heh.
Comment 11 Magnus Enger 2023-03-28 13:30:15 UTC
Sorry, patch does not apply and I don't see how to resolve the conflict: 

$ git bz apply 31841

Bug 31841 - Shelving location search in staff interface sometimes creates invalid Zebra query

141950 - Bug 31841: Use location,wrdl when searching Shelving location

Apply? [(y)es, (n)o, (i)nteractive] y
Applying: Bug 31841: Use location,wrdl when searching Shelving location
Using index info to reconstruct a base tree...
M	koha-tmpl/intranet-tmpl/prog/en/includes/search_indexes.inc
Falling back to patching base and 3-way merge...
Auto-merging koha-tmpl/intranet-tmpl/prog/en/includes/search_indexes.inc
CONFLICT (content): Merge conflict in koha-tmpl/intranet-tmpl/prog/en/includes/search_indexes.inc
error: Failed to merge in the changes.
Patch failed at 0001 Bug 31841: Use location,wrdl when searching Shelving location
hint: Use 'git am --show-current-patch=diff' to see the failed patch
When you have resolved this problem run "git bz apply --continue".
If you would prefer to skip this patch, instead run "git bz apply --skip".
To restore the original branch and stop patching run "git bz apply --abort".
Patch left in /tmp/Bug-31841-Use-locationwrdl-when-searching-Shelving-qsJQXm.patch

<<<<<<< HEAD
[% IF ms_location %]
        <option selected="selected" value="location" title="Enter location code value for search">Shelving location (code)</option>
=======
    [% IF ms_locationcommawrdl %]
        <option selected="selected" value="location,wrdl" title="Enter location code value for search">Shelving location (code)</option>
>>>>>>> Bug 31841: Use location,wrdl when searching Shelving location
Comment 12 David Cook 2023-03-29 00:30:18 UTC
Thanks for looking Magnus. It's a simple fix. I'll look at doing that now actually...
Comment 13 David Cook 2023-03-29 00:31:49 UTC
(In reply to Fridolin Somers from comment #9)
> > since "location" doesn't have a phrase index defined...
> Why not add it to Zebra MARC21 configuration ?
> 
> Even if unlikely :
> Imagine two locations "foo bar" and "bar foo", words list type search "wrdl"
> will match both.
> 
> This indexing can be useful for other cases.

It might be worth adding that the status quo right now is doing a "wrdl" search for "location", so I'm just trying to make the status quo explicit and functional in all cases.
Comment 14 David Cook 2023-03-29 00:34:45 UTC Comment hidden (obsolete)
Comment 15 Fridolin Somers 2023-03-29 07:34:06 UTC
(In reply to David Cook from comment #13)
> (In reply to Fridolin Somers from comment #9)
> > > since "location" doesn't have a phrase index defined...
> > Why not add it to Zebra MARC21 configuration ?
> > 
> > Even if unlikely :
> > Imagine two locations "foo bar" and "bar foo", words list type search "wrdl"
> > will match both.
> > 
> > This indexing can be useful for other cases.
> 
> It might be worth adding that the status quo right now is doing a "wrdl"
> search for "location", so I'm just trying to make the status quo explicit
> and functional in all cases.

OKi no problem.
A fix that works is a good fix ;)
Comment 16 Magnus Enger 2023-03-29 08:06:41 UTC
Created attachment 148856 [details] [review]
Bug 31841: Use location,wrdl when searching Shelving location

The "location" index only has a word index defined, so we need
to specify the wrdl qualifier when searching it via the staff
interface dropdown menu

Test plan:
1) Change QueryAutoTruncate to "only if * is added"
2) Change IntranetCatalogSearchPulldown to "Show"
3) Search for "Shelving location" of "GEN" in catalogue
search bar
4) Note no results returned

5) Apply patch
6) koha-plack --restart kohadev

7) Repeat Step #3
8) Note that results appear for 'location,wrdl: GEN'

Signed-off-by: Magnus Enger <magnus@libriotech.no>
Works as advertised.
Comment 17 Nick Clemens (kidclamp) 2023-03-29 13:38:48 UTC
Created attachment 148916 [details] [review]
Bug 31841: Use location,wrdl when searching Shelving location

The "location" index only has a word index defined, so we need
to specify the wrdl qualifier when searching it via the staff
interface dropdown menu

Test plan:
1) Change QueryAutoTruncate to "only if * is added"
2) Change IntranetCatalogSearchPulldown to "Show"
3) Search for "Shelving location" of "GEN" in catalogue
search bar
4) Note no results returned

5) Apply patch
6) koha-plack --restart kohadev

7) Repeat Step #3
8) Note that results appear for 'location,wrdl: GEN'

Signed-off-by: Magnus Enger <magnus@libriotech.no>
Works as advertised.
Signed-off-by: Nick Clemens <nick@bywatersolutions.com>
Comment 18 Tomás Cohen Arazi (tcohen) 2023-04-06 12:52:23 UTC
Pushed to master for 23.05.

Nice work everyone, thanks!
Comment 19 Jacob O'Mara 2023-04-16 20:37:09 UTC
Nice work, thanks everyone!

Pushed to 22.11.x for the next release.
Comment 20 Lucas Gass (lukeg) 2023-05-05 21:31:22 UTC
Doesn't apply cleanly to 22.05.x, no backport.
Comment 21 Fridolin Somers 2023-08-07 23:06:30 UTC
(In reply to David Cook from comment #3)
> In Master:
> 1) Turn off QueryAutoTruncate
> 2) Go to
> http://localhost:8081/cgi-bin/koha/catalogue/search.pl?q=GEN&idx=location
> 3) Note "No results found"
> 
> The problem is that QueryWeightFields adds a "phr" qualifier which is a
> problem since "location" doesn't have a phrase index defined...:
> 
> (rk=( location,ext,r1=" GEN " or location,phr,r3=" GEN " or
> location,wrdl,r6=" GEN " or location,wrdl,fuzzy,r8=" GEN " or
> location,wrdl,rt,r9=""gen"? "))

We have seen other problems like that.
We should add phrase search to all search fields to fix once and for all.

But for this cas, it disables autotruncation of location code, so its a good fix.