Bug 25229

Summary: Elasticsearch should use the authid (record id) rather than the 001 when returning auth search results
Product: Koha Reporter: Nick Clemens (kidclamp) <nick>
Component: Searching - ElasticsearchAssignee: Nick Clemens (kidclamp) <nick>
Status: CLOSED FIXED QA Contact:
Severity: normal    
Priority: P5 - low CC: 1joynelson, andrew, jonathan.druart, m.de.rooy
Version: Main   
Hardware: All   
OS: All   
Change sponsored?: --- Patch complexity: ---
Documentation contact: Documentation submission:
Text to go in the release notes:
Version(s) released in:
20.05.00, 19.11.06
Circulation function:
Attachments: Bug 25229: Return authid of record rather than 001
Bug 25229: Return authid of record rather than 001
Bug 25229: Unit test
Bug 25229: Return authid of record rather than 001
Bug 25229: (follow-up) Move QueryBuilder test to Elasticsearch dir
Bug 25229: Unit test
Bug 25229: Return authid of record rather than 001
Bug 25229: (follow-up) Move QueryBuilder test to Elasticsearch dir

Description Nick Clemens (kidclamp) 2020-04-21 13:38:37 UTC
To recreate:
0 - Have an environment with both ES and Zebra available
1 - Edit an authority record in the DB to force the 001 and the auth_id to be different
    update auth_header SET marcxml = REPLACE(marcxml,"1707","potato");
2 - Reindex Zebra and ES
3 - View the record in zebra (commands below work on kohadevbox sample data)
    yaz-client unix:/var/run/koha/kohadev/authoritysocket
    base authorities
    find "computer program"
    show 1+14
    Note that the relevant record has the auth id in the 001 even though the record doesn't
4 - View the record in Elasticsearch
    curl -X GET 'localhost:9200/koha_kohadev_authorities/data/1707?pretty'
    Note the 001 is indexed into local number, but the _id of the record matches authid
5 - Search authorities in the staff client for "Computer prorgram" using Zebra
    Note that you can find authid 1707 in the results and view it
6 - Switch search engine to ES and repeat
    Note that you have a result that links to authid=potato and it doesn't work
Comment 1 Nick Clemens (kidclamp) 2020-04-21 13:48:48 UTC
Created attachment 103376 [details] [review]
Bug 25229: Return authid of record rather than 001
Comment 2 Nick Clemens (kidclamp) 2020-04-21 13:52:17 UTC
As far as I can tell, we do this for zebra in the background. Follow the recreation instructions and see that we index the authid as 001 even if the record is different, which is kinda crazy.

We should at least be consistent.

I have not included tests because we don't really yet have a way to fake ES for tests - we need bug 19821 as there are issues where records created for testing are indexed into ES if search engine config is set, but they don't get removed (for zebra they enter zebraqueue transactionally and are not committed)

Everywhere this code is sued expects the correct authid afacit
Comment 3 Frédéric Demians 2020-04-27 07:32:41 UTC
Created attachment 103738 [details] [review]
Bug 25229: Return authid of record rather than 001

Signed-off-by: Frédéric Demians <f.demians@tamil.fr>
Document _id field, in authorities ES index, is always authid
Comment 4 Jonathan Druart 2020-04-27 10:16:02 UTC
Tests please?
Comment 5 Nick Clemens (kidclamp) 2020-04-27 11:34:23 UTC
Created attachment 103759 [details] [review]
Bug 25229: Unit test
Comment 6 Nick Clemens (kidclamp) 2020-04-27 11:34:26 UTC
Created attachment 103760 [details] [review]
Bug 25229: Return authid of record rather than 001

Signed-off-by: Frédéric Demians <f.demians@tamil.fr>
Document _id field, in authorities ES index, is always authid
Comment 7 Nick Clemens (kidclamp) 2020-04-27 11:37:36 UTC
Created attachment 103761 [details] [review]
Bug 25229: (follow-up) Move QueryBuilder test to Elasticsearch dir
Comment 8 Jonathan Druart 2020-04-27 12:49:16 UTC
Created attachment 103779 [details] [review]
Bug 25229: Unit test

Signed-off-by: Jonathan Druart <jonathan.druart@bugs.koha-community.org>
Comment 9 Jonathan Druart 2020-04-27 12:49:20 UTC
Created attachment 103780 [details] [review]
Bug 25229: Return authid of record rather than 001

Signed-off-by: Frédéric Demians <f.demians@tamil.fr>
Document _id field, in authorities ES index, is always authid

Signed-off-by: Jonathan Druart <jonathan.druart@bugs.koha-community.org>
Comment 10 Jonathan Druart 2020-04-27 12:49:24 UTC
Created attachment 103781 [details] [review]
Bug 25229: (follow-up) Move QueryBuilder test to Elasticsearch dir

Signed-off-by: Jonathan Druart <jonathan.druart@bugs.koha-community.org>
Comment 11 Martin Renvoize (ashimema) 2020-04-29 15:25:28 UTC
Nice work everyone!

Pushed to master for 20.05
Comment 12 Joy Nelson 2020-05-08 22:12:09 UTC
Backported to 19.11.x for 19.11.06