From f76eaa78249ccb893f948aa71b3e36571b75e61b Mon Sep 17 00:00:00 2001
From: Alex Buckley <alexbuckley@catalyst.net.nz>
Date: Mon, 13 May 2024 18:13:07 +0000
Subject: [PATCH] Bug 36727: Add new issn-all Elasticsearch index for MARC21

- This index searches 022ayz, 023ayz (MARC21) and 011ayz (UNIMARC).
- 011y and 011z have been removed from issn search field for UNIMARC.
- 022yz and 023yz have also been added to the identifier-standard search field

Test plan:
1. Start up KTD with Elasticsearch: ktd --es8 up

2. Add a new biblio record putting the value '0046-2254' into the incorrect ISSN subfield (022y /023y for MARC21, or 011z for UNIMARC)

3. Do a biblio search for '0046-2254' and confirm no results are returned

4. Apply this patch and restart all services (restart_all)

5. Reset the mappings: Administration > Catalog > Search engine configuration (Elasticsearch) > Reset mappings (at the bottom of the page)

6. Reindex: koha-elasticsearch --rebuild -d -b -a kohadev

7. Alternative to steps 5 and 6: reset_all

8. Repeat the biblio search for '0046-2254' and confirm you get a result

Sponsored-by: Education Services Australia SCIS
Signed-off-by: Janusz Kaczmarek <januszop@gmail.com>
Signed-off-by: David Nind <david@davidnind.com>
Signed-off-by: Nick Clemens <nick@bywatersolutions.com>
---
 .../searchengine/elasticsearch/mappings.yaml  | 29 ++++++++++++++++++-
 1 file changed, 28 insertions(+), 1 deletion(-)

diff --git a/admin/searchengine/elasticsearch/mappings.yaml b/admin/searchengine/elasticsearch/mappings.yaml
index 929f2f94103..929d62b08a9 100644
--- a/admin/searchengine/elasticsearch/mappings.yaml
+++ b/admin/searchengine/elasticsearch/mappings.yaml
@@ -2034,7 +2034,12 @@ biblios:
       sort: 1
       suggestible: ''
     - facet: ''
-      marc_field: 022a
+      marc_field: 022ayz
+      marc_type: marc21
+      sort: 1
+      suggestible: ''
+    - facet: ''
+      marc_field: 023ayz
       marc_type: marc21
       sort: 1
       suggestible: ''
@@ -2154,6 +2159,28 @@ biblios:
       marc_type: marc21
       sort: 1
       suggestible: ''
+    - facet: ''
+      marc_field: 011a
+      marc_type: unimarc
+      sort: 1
+      suggestible: ''
+    opac: 1
+    staff_client: 1
+    type: stdno
+  issn-all:
+    label: issn-all
+    mandatory: ~
+    mappings:
+    - facet: ''
+      marc_field: 022ayz
+      marc_type: marc21
+      sort: 1
+      suggestible: ''
+    - facet: ''
+      marc_field: 023ayz
+      marc_type: marc21
+      sort: 1
+      suggestible: ''
     - facet: ''
       marc_field: 011ayz
       marc_type: unimarc
-- 
2.39.2