Bug 36396

Summary: Link facet with authorised value category
Product: Koha Reporter: Jonathan Druart <jonathan.druart>
Component: Searching - ElasticsearchAssignee: Jonathan Druart <jonathan.druart>
Status: RESOLVED FIXED QA Contact: Martin Renvoize (ashimema) <martin.renvoize>
Severity: enhancement    
Priority: P5 - low CC: caroline.cyr-la-rose, clemens.tubach, fridolin.somers, michaela.sieber, nick
Version: unspecified   
Hardware: All   
OS: All   
Change sponsored?: Sponsored Patch complexity: ---
Documentation contact: Caroline Cyr La Rose Documentation submission: https://gitlab.com/koha-community/koha-manual/-/merge_requests/953
Text to go in the release notes:
This new feature adds the ability to link an Elasticsearch facet to an authorized value category in order to display a description instead of the code. An example could be a code for the resource type (book, e-journal, database, etc.) if this code is in a local MARC 9xx field. This feature depends on Bug 35138 - configuration of facets with Elasticsearch.
Version(s) released in:
24.05.00
Circulation function:
Bug Depends on: 35138    
Bug Blocks: 36398    
Attachments: Bug 36396: DB changes
Bug 36396: DBIC schema changes
Bug 36396: Link facet with authorised value category - ES
Bug 36396: Prevent link to av for 'specials'
Bug 36396: UI - OPAC
Bug 36396: Export/import the yaml config
Bug 36396: (follow-up) Prevent link to av for 'specials'
Bug 36396: DB changes
Bug 36396: DBIC schema changes
Bug 36396: Link facet with authorised value category - ES
Bug 36396: Prevent link to av for 'specials'
Bug 36396: UI - OPAC
Bug 36396: Export/import the yaml config
Bug 36396: (follow-up) Prevent link to av for 'specials'
Bug 36396: DB changes
Bug 36396: DBIC schema changes
Bug 36396: Link facet with authorised value category - ES
Bug 36396: Prevent link to av for 'specials'
Bug 36396: UI - OPAC
Bug 36396: Export/import the yaml config
Bug 36396: (follow-up) Prevent link to av for 'specials'
Bug 36396: Add tests
Bug 36396: Add tests

Description Jonathan Druart 2024-03-22 09:13:52 UTC
In order to display descriptions instead of codes we will add a link to an authorised value category.
Comment 1 Jonathan Druart 2024-03-22 10:36:08 UTC
Created attachment 163685 [details] [review]
Bug 36396: DB changes

Add the new DB column search_field.authorised_value_category

Sponsored-by: The Research University in the Helmholtz Association (KIT)
Comment 2 Jonathan Druart 2024-03-22 10:36:10 UTC
Created attachment 163686 [details] [review]
Bug 36396: DBIC schema changes

Sponsored-by: The Research University in the Helmholtz Association (KIT)
Comment 3 Jonathan Druart 2024-03-22 10:36:13 UTC
Created attachment 163687 [details] [review]
Bug 36396: Link facet with authorised value category - ES

This new feature adds the ability to link an ES facet to an authorised
value category, in order to display a description instead of the code.

Test plan:
1. Go to the ES mapping admin page
2. Notice the new "Authorized value category" column in the facets
   config table
3. Create a new facet that is linked to a search field containing values
   from an authorised value category. Pick this category in the list
4. Save
5. Reindex
6. Notice that the descriptions are now displayed (staff and OPAC) in
   the search result page.

QA: See the related bug report for possible improvements. It's not
easy at all to deal with the "specials" here, a lot of changes must be
done in how we fetch/cache the AVs.

Sponsored-by: The Research University in the Helmholtz Association (KIT)
Comment 4 Jonathan Druart 2024-03-22 10:36:15 UTC
Created attachment 163688 [details] [review]
Bug 36396: Prevent link to av for 'specials'

See previous commit message, 'QA' part.
We do not support the "specials" categories.

Sponsored-by: The Research University in the Helmholtz Association (KIT)
Comment 5 Jonathan Druart 2024-03-22 10:36:17 UTC
Created attachment 163689 [details] [review]
Bug 36396: UI - OPAC

Sponsored-by: The Research University in the Helmholtz Association (KIT)
Comment 6 Jonathan Druart 2024-03-22 10:36:19 UTC
Created attachment 163690 [details] [review]
Bug 36396: Export/import the yaml config

Test plan:
Export the ES fields/mappings using
 misc/search_tools/export_elasticsearch_mappings.pl > mappings.yaml
Copy this file to admin/searchengine/elasticsearch/mappings.yaml

Reset the mapping from the UI
Notice that the links to the AV categories have been preserved

Sponsored-by: The Research University in the Helmholtz Association (KIT)
Comment 7 Michaela Sieber 2024-03-22 13:31:26 UTC
Thanks Jonathan!

Just a very small thing:
 When adding a new line to the facets config table 'Facet order' it is not possible to leave the authorised value category empty. You first have to add the line and save, afterwards you can change the authorised value category to be empty.
Comment 8 Jonathan Druart 2024-03-22 13:37:35 UTC
Created attachment 163705 [details] [review]
Bug 36396: (follow-up) Prevent link to av for 'specials'
Comment 9 Jonathan Druart 2024-03-22 13:38:20 UTC
(In reply to Michaela Sieber from comment #7)
> Thanks Jonathan!
> 
> Just a very small thing:
>  When adding a new line to the facets config table 'Facet order' it is not
> possible to leave the authorised value category empty. You first have to add
> the line and save, afterwards you can change the authorised value category
> to be empty.

Indeed, thanks! Should be fixed now.
Comment 10 Lukas Koszyk 2024-03-25 10:10:42 UTC
Created attachment 163776 [details] [review]
Bug 36396: DB changes

Add the new DB column search_field.authorised_value_category

Sponsored-by: Karlsruhe Institute of Technology (KIT)
Signed-off-by: Lukas Koszyk <lukasz.koszyk@kit.edu>
Comment 11 Lukas Koszyk 2024-03-25 10:10:44 UTC
Created attachment 163777 [details] [review]
Bug 36396: DBIC schema changes

Sponsored-by: The Research University in the Helmholtz Association (KIT)
Signed-off-by: Lukas Koszyk <lukasz.koszyk@kit.edu>
Comment 12 Lukas Koszyk 2024-03-25 10:10:47 UTC
Created attachment 163778 [details] [review]
Bug 36396: Link facet with authorised value category - ES

This new feature adds the ability to link an ES facet to an authorised
value category, in order to display a description instead of the code.

Test plan:
1. Go to the ES mapping admin page
2. Notice the new "Authorized value category" column in the facets
   config table
3. Create a new facet that is linked to a search field containing values
   from an authorised value category. Pick this category in the list
4. Save
5. Reindex
6. Notice that the descriptions are now displayed (staff and OPAC) in
   the search result page.

QA: See the related bug report for possible improvements. It's not
easy at all to deal with the "specials" here, a lot of changes must be
done in how we fetch/cache the AVs.

Sponsored-by: The Research University in the Helmholtz Association (KIT)
Signed-off-by: Lukas Koszyk <lukasz.koszyk@kit.edu>
Comment 13 Lukas Koszyk 2024-03-25 10:10:49 UTC
Created attachment 163779 [details] [review]
Bug 36396: Prevent link to av for 'specials'

See previous commit message, 'QA' part.
We do not support the "specials" categories.

Sponsored-by: The Research University in the Helmholtz Association (KIT)
Signed-off-by: Lukas Koszyk <lukasz.koszyk@kit.edu>
Comment 14 Lukas Koszyk 2024-03-25 10:10:51 UTC
Created attachment 163780 [details] [review]
Bug 36396: UI - OPAC

Sponsored-by: The Research University in the Helmholtz Association (KIT)
Signed-off-by: Lukas Koszyk <lukasz.koszyk@kit.edu>
Comment 15 Lukas Koszyk 2024-03-25 10:10:53 UTC
Created attachment 163781 [details] [review]
Bug 36396: Export/import the yaml config

Test plan:
Export the ES fields/mappings using
 misc/search_tools/export_elasticsearch_mappings.pl > mappings.yaml
Copy this file to admin/searchengine/elasticsearch/mappings.yaml

Reset the mapping from the UI
Notice that the links to the AV categories have been preserved

Sponsored-by: The Research University in the Helmholtz Association (KIT)
Signed-off-by: Lukas Koszyk <lukasz.koszyk@kit.edu>
Comment 16 Lukas Koszyk 2024-03-25 10:10:56 UTC
Created attachment 163782 [details] [review]
Bug 36396: (follow-up) Prevent link to av for 'specials'

Signed-off-by: Lukas Koszyk <lukasz.koszyk@kit.edu>
Comment 17 Katrin Fischer 2024-04-30 09:17:47 UTC
With bug 35138 being pushed today, this would make a lot of sense to "round off" the feature for this release.
Comment 18 Martin Renvoize (ashimema) 2024-05-07 10:21:25 UTC
Created attachment 166246 [details] [review]
Bug 36396: DB changes

Add the new DB column search_field.authorised_value_category

Sponsored-by: The Research University in the Helmholtz Association (KIT)
Signed-off-by: Lukas Koszyk <lukasz.koszyk@kit.edu>
Signed-off-by: Martin Renvoize <martin.renvoize@ptfs-europe.com>
Comment 19 Martin Renvoize (ashimema) 2024-05-07 10:21:28 UTC
Created attachment 166247 [details] [review]
Bug 36396: DBIC schema changes

Sponsored-by: The Research University in the Helmholtz Association (KIT)
Signed-off-by: Lukas Koszyk <lukasz.koszyk@kit.edu>
Signed-off-by: Martin Renvoize <martin.renvoize@ptfs-europe.com>
Comment 20 Martin Renvoize (ashimema) 2024-05-07 10:21:31 UTC
Created attachment 166248 [details] [review]
Bug 36396: Link facet with authorised value category - ES

This new feature adds the ability to link an ES facet to an authorised
value category, in order to display a description instead of the code.

Test plan:
1. Go to the ES mapping admin page
2. Notice the new "Authorized value category" column in the facets
   config table
3. Create a new facet that is linked to a search field containing values
   from an authorised value category. Pick this category in the list
4. Save
5. Reindex
6. Notice that the descriptions are now displayed (staff and OPAC) in
   the search result page.

QA: See the related bug report for possible improvements. It's not
easy at all to deal with the "specials" here, a lot of changes must be
done in how we fetch/cache the AVs.

Sponsored-by: The Research University in the Helmholtz Association (KIT)
Signed-off-by: Lukas Koszyk <lukasz.koszyk@kit.edu>
Signed-off-by: Martin Renvoize <martin.renvoize@ptfs-europe.com>
Comment 21 Martin Renvoize (ashimema) 2024-05-07 10:21:34 UTC
Created attachment 166249 [details] [review]
Bug 36396: Prevent link to av for 'specials'

See previous commit message, 'QA' part.
We do not support the "specials" categories.

Sponsored-by: The Research University in the Helmholtz Association (KIT)
Signed-off-by: Lukas Koszyk <lukasz.koszyk@kit.edu>
Signed-off-by: Martin Renvoize <martin.renvoize@ptfs-europe.com>
Comment 22 Martin Renvoize (ashimema) 2024-05-07 10:21:37 UTC
Created attachment 166250 [details] [review]
Bug 36396: UI - OPAC

Sponsored-by: The Research University in the Helmholtz Association (KIT)
Signed-off-by: Lukas Koszyk <lukasz.koszyk@kit.edu>
Signed-off-by: Martin Renvoize <martin.renvoize@ptfs-europe.com>
Comment 23 Martin Renvoize (ashimema) 2024-05-07 10:21:40 UTC
Created attachment 166251 [details] [review]
Bug 36396: Export/import the yaml config

Test plan:
Export the ES fields/mappings using
 misc/search_tools/export_elasticsearch_mappings.pl > mappings.yaml
Copy this file to admin/searchengine/elasticsearch/mappings.yaml

Reset the mapping from the UI
Notice that the links to the AV categories have been preserved

Sponsored-by: The Research University in the Helmholtz Association (KIT)
Signed-off-by: Lukas Koszyk <lukasz.koszyk@kit.edu>
Signed-off-by: Martin Renvoize <martin.renvoize@ptfs-europe.com>
Comment 24 Martin Renvoize (ashimema) 2024-05-07 10:21:43 UTC
Created attachment 166252 [details] [review]
Bug 36396: (follow-up) Prevent link to av for 'specials'

Signed-off-by: Lukas Koszyk <lukasz.koszyk@kit.edu>
Signed-off-by: Martin Renvoize <martin.renvoize@ptfs-europe.com>
Comment 25 Martin Renvoize (ashimema) 2024-05-07 10:22:37 UTC
This looks pretty good and works.. but we're missing unit tests for the additional functionality introduced into the Koha:: modules.
Comment 26 Jonathan Druart 2024-05-07 10:41:52 UTC
Created attachment 166254 [details] [review]
Bug 36396: Add tests
Comment 27 Martin Renvoize (ashimema) 2024-05-07 11:11:33 UTC
Created attachment 166258 [details] [review]
Bug 36396: Add tests

Signed-off-by: Martin Renvoize <martin.renvoize@ptfs-europe.com>
Comment 28 Martin Renvoize (ashimema) 2024-05-07 11:11:52 UTC
Nice one Jonathan,

Passing QA
Comment 29 Katrin Fischer 2024-05-07 13:56:12 UTC
Pushed for 24.05!

Well done everyone, thank you!
Comment 30 Fridolin Somers 2024-05-24 14:30:20 UTC
Depends on Bug 35138 not in 23.11.x