From 6fc84868ce294cfcb6753346b1462e13b0205663 Mon Sep 17 00:00:00 2001
From: Janusz Kaczmarek <januszop@gmail.com>
Date: Tue, 14 Mar 2023 14:22:27 +0100
Subject: [PATCH] Bug 36554: Document languages from field 041 should be
 present in 'ln' search field and Languages facet (MARC 21)

In Elasticsearch, the field 041 (subfields: a, d, e, i, j)
is not indexed with 'ln' search field.  As a result, records cannot
be found when searching with languages present in 041 (but only
with the one from 008/35-37), and the languages are also missing
from the facet.

Subfields content (only relevant subfields):
$a - Language code of text/sound track or separate title
$d - Language code of sung or spoken text
$e - Language code of librettos
$i - Language code of intertitles
$j - Language code of subtitles

Test plan
=========
0. Have a test installation with Elasticsearch.
1. In ktd with its test data, make a biblio search for a language present
   in 041 a/d/e/i/j but not in 008/35-37, e.g. for Japanese (with ln:jpn
   or from Advance search).  You will get no results.
2. Apply the patch, reindex with:
   sudo koha-elasticsearch --rebuild -r -b kohadev
3. Repeat the test. You should get some records and also you should see
   the Japanese language in the Languages facet.
---
 admin/searchengine/elasticsearch/mappings.yaml | 5 +++++
 1 file changed, 5 insertions(+)

diff --git a/admin/searchengine/elasticsearch/mappings.yaml b/admin/searchengine/elasticsearch/mappings.yaml
index 9cd3db5c96..1190bedd27 100644
--- a/admin/searchengine/elasticsearch/mappings.yaml
+++ b/admin/searchengine/elasticsearch/mappings.yaml
@@ -2493,6 +2493,11 @@ biblios:
       marc_type: marc21
       sort: 1
       suggestible: ''
+    - facet: 1
+      marc_field: 041adeij
+      marc_type: marc21
+      sort: 1
+      suggestible: ''
     - facet: 1
       marc_field: 101a
       marc_type: unimarc
-- 
2.30.2