Bug 33802 - On OPAC authority detail page, usage count in wrong (when using Elasticsearch)
Summary: On OPAC authority detail page, usage count in wrong (when using Elasticsearch)
Status: Failed QA
Alias: None
Product: Koha
Classification: Unclassified
Component: OPAC (show other bugs)
Version: Main
Hardware: All All
: P5 - low trivial
Assignee: Frédéric Demians
QA Contact: Testopia
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2023-05-23 08:19 UTC by Frédéric Demians
Modified: 2024-09-13 14:34 UTC (History)
4 users (show)

See Also:
Change sponsored?: ---
Patch complexity: ---
Documentation contact:
Documentation submission:
Text to go in the release notes:
This fixes the usage count shown on authority details pages in the OPAC (and the staff interface) - "Number of records used in: X". Note: This only occurs when using the Elasticsearch or Open Search search engine. Previously, where QueryAutoTruncate is enabled, the usage count for an authority may have been wrong as the search was automatically truncated (for example, a search for records using authority 22 also retrieved using authorities 222, 22*, and so on).
Version(s) released in:
Circulation function:


Attachments
Bug 33802: On OPAC authority detail page, usage count in erroneous (1.57 KB, patch)
2023-05-23 08:40 UTC, Frédéric Demians
Details | Diff | Splinter Review
Bug 33802: On OPAC authority detail page, usage count in erroneous (1.62 KB, patch)
2023-05-25 12:42 UTC, David Nind
Details | Diff | Splinter Review

Note You need to log in before you can comment on or make changes to this bug.
Description Frédéric Demians 2023-05-23 08:19:33 UTC
On OPAC opac-authoritiesdetail.pl page, usage count is wrong.
Comment 1 Frédéric Demians 2023-05-23 08:40:31 UTC
Created attachment 151553 [details] [review]
Bug 33802: On OPAC authority detail page, usage count in erroneous

If QueryAutoTruncate is enabled, the biblio usage count of an authority
displayed on OPAC may be wrong. This is due to the fact that the authid
search being automatically truncated, a search for biblios using
authority 22 will retrieved also biblios using authorities 222, 22*.

TO TEST:

1. On a Koha with authorities, enable QueryAutoTruncate.
2. Go on opac-authoritiesdetail.pl page for an authority with the lowest
   possible authid. Let say 1.
3. Confirm that you have a large biblios usage count, and that by
   clicking on the link to see linked biblios, you get far less biblios
   than expected.
4. Apply the patch. Repeat 2-3.
Comment 2 David Nind 2023-05-24 00:30:29 UTC
I couldn't replicate the issue when using Zebra, but can when using Elasticsearch.

So is this Elasticsearch specific?

After the patch is applied, it fixes things for Elasticsearch, and I noticed no changes when using Zebra.

Testing notes using koha-testing-docker and the sample data:

1. I'm assuming by enable QueryAutoTruncate, this means to set it to 'automatically' (the default in KTD).

2. I can't replicate the issue using Zebra: for authid=1 there are no results (as expected).

3. However, I can replicate the issue when using Elasticsearch: for authid=1 the details page shows 152 usages, clicking on the link shows no results; using authid=11 I get 12 usages, but only one actual result.
Comment 3 Frédéric Demians 2023-05-25 10:21:20 UTC
Yes, it's ES specific.
Comment 4 David Nind 2023-05-25 12:40:21 UTC
(In reply to Frédéric Demians from comment #3)
> Yes, it's ES specific.

Thanks! Sign off coming for this patch that fixes the OPAC (and staff interface).

I also noticed that this is occurring on the staff interface as well. This bug fixes the display for the staff interface authority details page - "Used in X records". But it doesn't fix the actual results. For example, authid=3 shows used in 1 record, but you get 44 records in the actual results. I vaguely remember testing a similar bug a while ago, but can't find it now...
Comment 5 David Nind 2023-05-25 12:42:43 UTC
Created attachment 151675 [details] [review]
Bug 33802: On OPAC authority detail page, usage count in erroneous

If QueryAutoTruncate is enabled, the biblio usage count of an authority
displayed on OPAC may be wrong. This is due to the fact that the authid
search being automatically truncated, a search for biblios using
authority 22 will retrieved also biblios using authorities 222, 22*.

TO TEST:

1. On a Koha with authorities, enable QueryAutoTruncate.
2. Go on opac-authoritiesdetail.pl page for an authority with the lowest
   possible authid. Let say 1.
3. Confirm that you have a large biblios usage count, and that by
   clicking on the link to see linked biblios, you get far less biblios
   than expected.
4. Apply the patch. Repeat 2-3.

Signed-off-by: David Nind <david@davidnind.com>
Comment 6 Fridolin Somers 2023-06-20 06:53:18 UTC
Like said in Bug 24143 search on 'an' should never use auto-truncate.
This is a more general issue.

I bet this change needs a UT.
Comment 7 Katrin Fischer 2023-06-22 18:37:48 UTC
We made this change in other spots, so no issue with that, but a unit test/regression test indeed would be nice.
Comment 8 Fridolin Somers 2024-05-23 12:11:45 UTC
Obsolete since Bug 32707 ?
Comment 9 David Nind 2024-05-23 22:26:03 UTC
(In reply to Fridolin Somers from comment #8)
> Obsolete since Bug 32707 ?

My testing shows that this is no longer an issue in main (for the OPAC and staff interface).

However, one I tested was C (Computer program language) (Topical Term) - authid=2 (<opac-url>:8080/cgi-bin/koha/opac-authoritiesdetail.pl?authid=2). It shows as not used any records. However, it is used in record 4 (The C programming language / Brian W. Kernighan, Dennis M. Ritchie.).

Probably this is another issue or related to the record details.
Comment 10 David Cook 2024-05-24 00:11:39 UTC
Certainly an interesting one I may come back to at some point...