From aa612ff9ee990cd7713c99f5b5a3bd9295669092 Mon Sep 17 00:00:00 2001 From: Mathieu Saby Date: Tue, 14 Jan 2025 18:02:54 +0000 Subject: [PATCH] Bug 38336: Fix confusion between 099 and 942 UNIMARC fields This patch fixes 099 and 942 fields (and incidentally 200$b) in the default and the FA UNIMARC frameworks and provides the changes that follow logically : - Zebra and Elasticsearch indexing - removal of the unused TYPEDOC authorized values category - UNIMARC facets in Koha.pm - test in TestBuilder.pm These changes are minimal and are intended to correct only the most serious problems. Subsequent work may bring improvements. Detail of changes : - The 099 field is renamed "Local dates (Koha)" and should be used in default configuration only for this storing creation and modification dates of record. - The 942 field is mandatory (because its $c subfield is) and should be used for all other Koha local information, like its MARC21 counterpart. - The 200$b field is no more indexed (it is now obsolete in cataloguing standards, and its MARC21 counterpart is not indexed). - Like in MARC21, ccode is now defined only at item level and itemtype/itype is now defined at item and biblio level. - The default values for itemtype at biblio and item level are the same, controlled by itype values (document type). - The TYPEDOC authorized values category, which was used for controlling the value if itemtype at record level, is removed. - In Koha.pm UNIMARC facets are fixed to be a mirror of MARC21 facets: a facet for itemtypes is created, and the facet for ccode is now based only on items. - A test on record-level itemtype in TestBuilder.pm is fixed in order to replace 099 with 942 field. Test plan: Note that sample data in ktd and sandbox will need to be fixed once this patch is pushed (there is no data in 942$c for example). It may cause warnings if you edit existing record but it is not a bug. A. Check framework changes 1/ In a UNIMARC k-t-d or sandbox, with Zebra search engine 2/ Apply the patch 3/ Check default and FA framework - 099 should be labelled "Local dates (Koha)" and contain 2 subfields:c and d - 942 should be mandatory, labelled "ADDED ENTRY ELEMENTS (Koha)" and contain 5 subfields : 0,2,6,c (mandatory),s 4/ Create a new record with default framework -- add a 200$a field, a 100$a field (with the cataloging plugin) -- in 942$c field, check that the values in dropdown list are the one defines for 'item types' in administration (Books, Computer Files, Continuing Resource, etc). -- Choose the value "Computer field" and Save the record -- Koha displays the item creation form. Check that the preselected value in 995$r (item type) is "Computer field" 5 / Do the same operation for a new record with FA framework B. Check Zebra indexing changes 6 / Search "livre" in the catalog. 419 results should be shown 7 / Check that an "Item type" facet is visible and functional 8 / Edit the first record of the result list, change its 942$c value and save 9 / Edit an item of that record and change the 995$r value (with a value different from the 942$c) and the 995$h value (3 possible values: Non-fiction, Fiction, Reference) 10 / Refresh the search for "livre" 11 / Check that the facet "Item types" has been updated and that a facet "Collections" is shown (from the 995$h) and functional C. Check Elasticsearch indexing changes 12 / I believe you cannot currently test Elasticsearch in a sandbox, so, open a new k-t-d with Elasticsearch search engine (ktd --es7 up) 13 / Repeat operations 6 to 11 in that new instance (277 results should be shown after the search in step 6, instead of 419 for Zebra, this is normal) --- C4/Koha.pm | 8 +- .../searchengine/elasticsearch/mappings.yaml | 14 +++- .../unimarc/biblios/biblio-koha-indexdefs.xml | 31 +++---- .../biblios/biblio-zebra-indexdefs.xsl | 84 +++++++++---------- .../mandatory/unimarc_framework_DEFAULT.yml | 60 +------------ .../unimarc_sample_fastadd_framework.yml | 4 +- .../data/mysql/mandatory/auth_val_cat.sql | 3 +- t/lib/TestBuilder.pm | 2 +- 8 files changed, 79 insertions(+), 127 deletions(-) diff --git a/C4/Koha.pm b/C4/Koha.pm index 1c3e2ceb2d..a63b8b8bf4 100644 --- a/C4/Koha.pm +++ b/C4/Koha.pm @@ -340,6 +340,12 @@ sub getFacets { tags => [ qw/ 225a / ], sep => ', ', }, + { + idx => 'itype', + label => 'Item types', + tags => [ qw/ 995r 942c / ], + sep => ', ', + }, { idx => 'location', label => 'Location', @@ -348,7 +354,7 @@ sub getFacets { { idx => 'ccode', label => 'Collections', - tags => [ qw / 099t 955h / ], + tags => [ qw / 995h / ], } ]; diff --git a/admin/searchengine/elasticsearch/mappings.yaml b/admin/searchengine/elasticsearch/mappings.yaml index 139d66ffc4..cd1eeaabbe 100644 --- a/admin/searchengine/elasticsearch/mappings.yaml +++ b/admin/searchengine/elasticsearch/mappings.yaml @@ -1351,7 +1351,7 @@ biblios: sort: 1 suggestible: '' - facet: 1 - marc_field: '9958' + marc_field: '995h' marc_type: unimarc sort: 1 suggestible: '' @@ -2255,6 +2255,11 @@ biblios: marc_type: marc21 sort: 1 suggestible: '' + - facet: '' + marc_field: 942c + marc_type: unimarc + sort: 1 + suggestible: '' opac: 1 staff_client: 1 type: '' @@ -2274,7 +2279,7 @@ biblios: sort: 1 suggestible: '' - facet: 1 - marc_field: 200b + marc_field: 942c marc_type: unimarc sort: 1 suggestible: '' @@ -4403,6 +4408,11 @@ biblios: marc_type: marc21 sort: 1 suggestible: '' + - facet: '' + marc_field: '9420' + marc_type: unimarc + sort: 1 + suggestible: '' opac: 1 staff_client: 1 type: '' diff --git a/etc/zebradb/marc_defs/unimarc/biblios/biblio-koha-indexdefs.xml b/etc/zebradb/marc_defs/unimarc/biblios/biblio-koha-indexdefs.xml index 5425bc2ba6..55df730165 100644 --- a/etc/zebradb/marc_defs/unimarc/biblios/biblio-koha-indexdefs.xml +++ b/etc/zebradb/marc_defs/unimarc/biblios/biblio-koha-indexdefs.xml @@ -39,10 +39,6 @@ Date/time-last-modified:n Date/time-last-modified:y - - - ccode:w - ISBN:w @@ -103,15 +99,6 @@ EAN:w Identifier-standard:w - - - itemtype:w - itemtype:p - itype:w - itype:p - Material-type:w - Material-type:p - itemtype:w @@ -1446,12 +1433,15 @@ totalissues:n totalissues:s + + itemtype:w + itemtype:p + itype:w + itype:p + not-onloan-count:n - - ccode:0 - se:0 @@ -1488,6 +1478,9 @@ au:0 + + itype:0 + homebranch:0 @@ -1500,5 +1493,7 @@ ccode:0 - - + + itype:0 + + diff --git a/etc/zebradb/marc_defs/unimarc/biblios/biblio-zebra-indexdefs.xsl b/etc/zebradb/marc_defs/unimarc/biblios/biblio-zebra-indexdefs.xsl index 22d902c461..b5ae8ce951 100644 --- a/etc/zebradb/marc_defs/unimarc/biblios/biblio-zebra-indexdefs.xsl +++ b/etc/zebradb/marc_defs/unimarc/biblios/biblio-zebra-indexdefs.xsl @@ -87,13 +87,6 @@ definition file (probably something like {biblio,authority}-koha-indexdefs.xml) - - - - - - - @@ -217,36 +210,6 @@ definition file (probably something like {biblio,authority}-koha-indexdefs.xml) - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - @@ -643,6 +606,29 @@ definition file (probably something like {biblio,authority}-koha-indexdefs.xml) + + + + + + + + + + + + + + + + + + + + + + + @@ -1882,6 +1868,13 @@ definition file (probably something like {biblio,authority}-koha-indexdefs.xml) + + + + + + + @@ -2542,13 +2535,6 @@ definition file (probably something like {biblio,authority}-koha-indexdefs.xml) - - - - - - - @@ -2661,6 +2647,13 @@ definition file (probably something like {biblio,authority}-koha-indexdefs.xml) + + + + + + + @@ -2675,6 +2668,9 @@ definition file (probably something like {biblio,authority}-koha-indexdefs.xml) + + + diff --git a/installer/data/mysql/en/marcflavour/unimarc/mandatory/unimarc_framework_DEFAULT.yml b/installer/data/mysql/en/marcflavour/unimarc/mandatory/unimarc_framework_DEFAULT.yml index afc80b8425..d088e123fe 100644 --- a/installer/data/mysql/en/marcflavour/unimarc/mandatory/unimarc_framework_DEFAULT.yml +++ b/installer/data/mysql/en/marcflavour/unimarc/mandatory/unimarc_framework_DEFAULT.yml @@ -423,8 +423,8 @@ tables: multiline: [] rows: - tagfield: "099" - liblibrarian: "local dates" - libopac: "" + liblibrarian: "Local dates (Koha)" + libopac: "Local dates (Koha)" repeatable: 0 mandatory: 0 authorised_value: @@ -470,60 +470,6 @@ tables: link: "" defaultvalue: - - tagfield: "099" - tagsubfield: "s" - liblibrarian: "Serial" - libopac: "Serial" - repeatable: 0 - mandatory: 0 - kohafield: biblio.serial - tab: 0 - authorised_value: - authtypecode: "" - value_builder: "" - isurl: 0 - hidden: 7 - frameworkcode: "" - seealso: "" - link: "" - defaultvalue: - - - tagfield: "099" - tagsubfield: "t" - liblibrarian: "Koha item type" - libopac: "Koha item type" - repeatable: 0 - mandatory: 1 - kohafield: biblioitems.itemtype - tab: 0 - authorised_value: TYPEDOC - authtypecode: "" - value_builder: "" - isurl: 0 - hidden: 0 - frameworkcode: "" - seealso: "" - link: "" - defaultvalue: - - - tagfield: "099" - tagsubfield: "x" - liblibrarian: "Number of issues" - libopac: "Number of issues" - repeatable: 0 - mandatory: 0 - kohafield: biblioitems.totalissues - tab: 0 - authorised_value: - authtypecode: "" - value_builder: "" - isurl: 0 - hidden: 6 - frameworkcode: "" - seealso: "" - link: "" - defaultvalue: "" - - marc_tag_structure: translatable: [ liblibrarian, libopac ] multiline: [] @@ -532,7 +478,7 @@ tables: liblibrarian: "ADDED ENTRY ELEMENTS (KOHA)" libopac: "ADDED ENTRY ELEMENTS (KOHA)" repeatable: 0 - mandatory: 0 + mandatory: 1 authorised_value: frameworkcode: "" diff --git a/installer/data/mysql/en/marcflavour/unimarc/optional/unimarc_sample_fastadd_framework.yml b/installer/data/mysql/en/marcflavour/unimarc/optional/unimarc_sample_fastadd_framework.yml index 0653a51e76..c729b60363 100644 --- a/installer/data/mysql/en/marcflavour/unimarc/optional/unimarc_sample_fastadd_framework.yml +++ b/installer/data/mysql/en/marcflavour/unimarc/optional/unimarc_sample_fastadd_framework.yml @@ -38,11 +38,11 @@ sql_statements: SELECT tagfield, liblibrarian, libopac, repeatable, mandatory, authorised_value, 'FA' FROM marc_tag_structure WHERE frameworkcode = '' AND - tagfield IN ('000', '001', '090', '099', '100', '200', '205', '210', '225', '995');" + tagfield IN ('000', '001', '090', '099', '100', '200', '205', '210', '225', '942', '995');" - "INSERT IGNORE INTO marc_subfield_structure (tagfield, tagsubfield, liblibrarian, libopac, repeatable, mandatory, kohafield, tab, authorised_value, authtypecode, value_builder, isurl, hidden, frameworkcode, seealso, link, defaultvalue) SELECT tagfield, tagsubfield, liblibrarian, libopac, repeatable, mandatory, kohafield, tab, authorised_value, authtypecode, value_builder, isurl, hidden, 'FA', seealso, link, defaultvalue FROM marc_subfield_structure WHERE frameworkcode = '' AND - tagfield IN ('000', '001', '090', '099', '100', '200', '205', '210', '225', '995');" + tagfield IN ('000', '001', '090', '099', '100', '200', '205', '210', '225', '942', '995');" diff --git a/installer/data/mysql/mandatory/auth_val_cat.sql b/installer/data/mysql/mandatory/auth_val_cat.sql index c1428e4a3c..b29a86749e 100644 --- a/installer/data/mysql/mandatory/auth_val_cat.sql +++ b/installer/data/mysql/mandatory/auth_val_cat.sql @@ -56,8 +56,7 @@ INSERT IGNORE INTO authorised_value_categories( category_name, is_system ) INSERT IGNORE INTO authorised_value_categories( category_name ) VALUES ('ETAT'), ('CAND'), - ('COUNTRY'), - ('TYPEDOC'), + ('COUNTRY'), ('qualif'); -- For Housebound diff --git a/t/lib/TestBuilder.pm b/t/lib/TestBuilder.pm index dc38cd5ae9..8032950087 100644 --- a/t/lib/TestBuilder.pm +++ b/t/lib/TestBuilder.pm @@ -177,7 +177,7 @@ sub build_sample_biblio { MARC::Field->new( $tag, ' ', ' ', $subfield => $author ), ); - ( $tag, $subfield ) = $marcflavour eq 'UNIMARC' ? ( '099', 't' ) : ( 942, 'c' ); + ( $tag, $subfield ) = $marcflavour eq 'UNIMARC' ? ( '942', 'c' ) : ( 942, 'c' ); $record->append_fields( MARC::Field->new( $tag, ' ', ' ', $subfield => $itemtype ) ); -- 2.39.5