From a78e55a2e1b905a3e7d74f70a234c14f2282d668 Mon Sep 17 00:00:00 2001
From: danyonsewell <danyonsewell@catalyst.net.nz>
Date: Wed, 1 May 2024 03:41:13 +0000
Subject: [PATCH] bug 36723: Add musical presentation to Elasticsearch index
 mappings

Have written a patch to allow Musical Presentation to be a search option within Elasticsearch index mappings

Test plan:

1. Apply this patch

2. Ensure MARC index 254 (Musical Presentation) is visible to edit on the default MARC bibliographic framework
   Koha Administration > MARC Bibliographic framework > Actions (under default framework) > MARC structure > Search 254 and actions->edit subfield > tick box for visibility should have OPAC, Staff Interface and Editor ticked.

3. Edit a record using the default MARC bibliographic framework and put a search term under index 254 and save.

4. Head back to the home page and go to Advanced Search

5. under the Search for dropdown select Musical presentation and in the search field enter the search term you used in step 3.

Your results should appear
---
 admin/searchengine/elasticsearch/mappings.yaml       | 12 ++++++++++++
 .../prog/en/includes/search_indexes.inc              |  5 +++++
 2 files changed, 17 insertions(+)

diff --git a/admin/searchengine/elasticsearch/mappings.yaml b/admin/searchengine/elasticsearch/mappings.yaml
index 16aaabfdbb..2713de1dd1 100644
--- a/admin/searchengine/elasticsearch/mappings.yaml
+++ b/admin/searchengine/elasticsearch/mappings.yaml
@@ -2697,6 +2697,18 @@ biblios:
     opac: 1
     staff_client: 1
     type: ''
+  musical-presentation:
+    label: musical-presentation
+    mandatory: ~
+    mappings:
+    - facet: ''
+      marc_field: '254'
+      marc_type: marc21
+      sort: 1
+      suggestible: ''
+    opac: 1
+    staff_client: 1
+    type: ''
   nal-call-number:
     label: nal-call-number
     mandatory: ~
diff --git a/koha-tmpl/intranet-tmpl/prog/en/includes/search_indexes.inc b/koha-tmpl/intranet-tmpl/prog/en/includes/search_indexes.inc
index f668fdcc9b..b36f7c22b6 100644
--- a/koha-tmpl/intranet-tmpl/prog/en/includes/search_indexes.inc
+++ b/koha-tmpl/intranet-tmpl/prog/en/includes/search_indexes.inc
@@ -169,6 +169,11 @@
     [% ELSE %]
         <option value="pl">Publisher location</option>
     [% END %]
+    [% IF ms_musicaldashpresentation %]
+        <option selected="selected" value="musical-presentation">Musical Presentation</option>
+    [% ELSE %]
+        <option value="musical-presentation">Musical Presentation</option>
+    [% END %]    
 
     [%# Use non-normalized st-year instead of st-numeric, %]
     [%# since pubdate can include 'u' to signify unknown %]
-- 
2.39.2