Bug 33842 - Search for authid not returning right results with QueryAutoTruncate ON
Summary: Search for authid not returning right results with QueryAutoTruncate ON
Status: RESOLVED WONTFIX
Alias: None
Product: Koha
Classification: Unclassified
Component: Searching - Elasticsearch (show other bugs)
Version: Main
Hardware: All All
: P5 - low normal (vote)
Assignee: Adolfo Rodríguez Taboada
QA Contact:
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2023-05-26 07:48 UTC by Adolfo Rodríguez Taboada
Modified: 2024-02-09 14:19 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:


Attachments
Don't add * when searching an authid (1.04 KB, patch)
2023-05-26 07:57 UTC, Adolfo Rodríguez Taboada
Details | Diff | Splinter Review

Note You need to log in before you can comment on or make changes to this bug.
Description Adolfo Rodríguez Taboada 2023-05-26 07:48:17 UTC
Conditions to replicate this bug:
1) Preference QueryAutoTruncate activated
2) Have authorities with low authids
3) ElasticSearch, though it should also happen with Zebra.

You can try it on this demo, it's on the master branch.
Intranet: https://intranet.koha-community.es
OPAC: https://catalog.koha-community.es/
User demo/demo

The following searchs return different results:
1) Search in the catalog an:1 The QueryAutoTruncate adds * so it returns all the biblios that use authorities with authids that begin with 1, which are 81. That doesn't make sense as those authorities have nothing in common.
https://intranet.koha-community.es/cgi-bin/koha/catalogue/search.pl?q=an%3A1

2) The authority with the id 1 is Mika Ninagawa, if you search her in the Authorities module, it says the authority is being used in two records, which is correct.
https://intranet.koha-community.es/cgi-bin/koha/authorities/authorities-home.pl?op=do_search&type=intranet&marclist=mainmainentry&and_or=and&excluding=&value=mika&authtypecode=&operator=contains&orderby=HeadingAsc

3) In the authority detail, Koha makes the same query as in point 1 so it appears it's being used in 81 records.
https://intranet.koha-community.es/cgi-bin/koha/authorities/detail.pl?authid=1

I think this disparity in results can be confusing for librarians and readers, as they won't understand why Koha is recovering records that are unrelated to the author/subject...
Comment 1 Adolfo Rodríguez Taboada 2023-05-26 07:57:46 UTC
Created attachment 151724 [details] [review]
Don't add * when searching an authid

Change in the function _truncate_terms so it doesn't add * when searching an authid, as it's an autonumeric id so starting with the same numbers doesn't mean they are related.

To test
1 Make sure the system preference QueryAutoTruncate is turned ON
2 Search an authority with a low id (1,2...) and see that the number of records in the results page and in the detail page don't match.
3 Apply patch, restart services
4 Repeat step 2 and check that the number of records now match.
Comment 2 Katrin Fischer 2023-10-29 11:41:33 UTC
Maybe bug 32707 would fix this as well?
Comment 3 Janusz Kaczmarek 2023-10-29 13:11:33 UTC
(In reply to Katrin Fischer from comment #2)
> Maybe bug 32707 would fix this as well?

Yes, it would--in a more general way, IMHO, also solving a problem of sn:1 and the like.
Comment 4 Adolfo Rodríguez Taboada 2023-11-30 14:20:39 UTC
A more general solution would be better, so you may close this bug.
Comment 5 Katrin Fischer 2023-12-30 20:24:56 UTC
Please consider signing off bug 32707 then, it would really help to make things move forward.
Comment 6 Magnus Enger 2024-02-09 14:19:00 UTC
> A more general solution would be better, so you may close this bug.(In reply to Adolfo Rodríguez Taboada from comment #4)