Bug 41863

Summary: Facets generated from Authorized values sometimes show empty labels
Product: Koha Reporter: Janusz Kaczmarek <januszop>
Component: Searching - ElasticsearchAssignee: Janusz Kaczmarek <januszop>
Status: Signed Off --- QA Contact: Testopia <testopia>
Severity: minor    
Priority: P5 - low    
Version: unspecified   
Hardware: All   
OS: All   
GIT URL: Initiative type: ---
Sponsorship status: Sponsored Comma delimited list of Sponsors:
Crowdfunding goal: 0 Patch complexity: ---
Documentation contact: Documentation submission:
Text to go in the release notes:
Version(s) released in:
Circulation function:
Attachments: Bug 41863: Facets generated from Authorized values sometimes show empty labels
Bug 41863: Facets generated from Authorized values sometimes show empty labels

Description Janusz Kaczmarek 2026-02-17 10:52:45 UTC
With facets generated from Authorized values, it may happen that the 
list of authorized values lacks an entry for a code used in 
a record. In this case, an empty entry will appear in the 
facet list, with the number of uses but without any label.

It would be desirable to show at least the raw code, rather 
than an empty label. This makes it easier to see which code has no 
entry in the respective AV and to either add it or correct an 
erroneous code.
Comment 1 Janusz Kaczmarek 2026-02-17 11:07:58 UTC
Created attachment 193317 [details] [review]
Bug 41863: Facets generated from Authorized values sometimes show empty labels

With facets generated from Authorized values, it may happen that the
list of authorized values lacks an entry for a code used in
a record. In this case, an empty entry will appear in the
facet list, with the number of uses but without any label.

It would be desirable to show at least the raw code, rather
than an empty label. This makes it easier to see which code has no
entry in the respective AV and to either add it or correct an
erroneous code.

Test plan:
==========

1. Have a standard KTD installation with Elasticsearch.
2. Add AV COUNTRY_CODES category and add two pairs (Authorized
   value, Description):
   * enk - England
   * xxu - United States

3. In the admin/searchengine/elasticsearch/mappings.yaml file,
   correct the definition of the pl search field as follows:

   pl:
-    label: pl
+    facet_order: 24
+    label: Publication place
     mandatory: ~
+    authorised_value_category: COUNTRY_CODES
     mappings:
-    - facet: ''
+    - facet: 1
       marc_field: 008_/15-17
       marc_type: marc21
       sort: 1

4. Reindex ES with:
   koha-elasticsearch --rebuild -r -d -b kohadev

5. Set the displayFacetCount systempreference to 'Show'
6. Perform a general search in the OPAC or staff interface: *
   View the 'Publication place' facet and notice a dozen empty
   entries, with only the number of occurrences.
7. Apply the patch ; restart_all
8. Repeat p. 6. You will see country codes that you can now add to AV
   or correct.

BTW, note that the tiny correction to Search.pm is analogous to
setting the label for 'special' types (i.e. itype, location, ccode,
holdingbranch, homebranch) two lines above.

Sponsored-by: Ignatianum University in Cracow
Comment 2 Roman Dolny 2026-02-17 17:55:07 UTC
Created attachment 193328 [details] [review]
Bug 41863: Facets generated from Authorized values sometimes show empty labels

With facets generated from Authorized values, it may happen that the
list of authorized values lacks an entry for a code used in
a record. In this case, an empty entry will appear in the
facet list, with the number of uses but without any label.

It would be desirable to show at least the raw code, rather
than an empty label. This makes it easier to see which code has no
entry in the respective AV and to either add it or correct an
erroneous code.

Test plan:
==========

1. Have a standard KTD installation with Elasticsearch.
2. Add AV COUNTRY_CODES category and add two pairs (Authorized
   value, Description):
   * enk - England
   * xxu - United States

3. In the admin/searchengine/elasticsearch/mappings.yaml file,
   correct the definition of the pl search field as follows:

   pl:
-    label: pl
+    facet_order: 24
+    label: Publication place
     mandatory: ~
+    authorised_value_category: COUNTRY_CODES
     mappings:
-    - facet: ''
+    - facet: 1
       marc_field: 008_/15-17
       marc_type: marc21
       sort: 1

4. Reindex ES with:
   koha-elasticsearch --rebuild -r -d -b kohadev

5. Set the displayFacetCount systempreference to 'Show'
6. Perform a general search in the OPAC or staff interface: *
   View the 'Publication place' facet and notice a dozen empty
   entries, with only the number of occurrences.
7. Apply the patch ; restart_all
8. Repeat p. 6. You will see country codes that you can now add to AV
   or correct.

BTW, note that the tiny correction to Search.pm is analogous to
setting the label for 'special' types (i.e. itype, location, ccode,
holdingbranch, homebranch) two lines above.

Sponsored-by: Ignatianum University in Cracow
Signed-off-by: Roman Dolny <roman.dolny@jezuici.pl>