From 18737a0a205eb884fc1135e598e525e1de0bf5c1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20Demians?= Date: Tue, 26 Mar 2024 22:17:16 +0100 Subject: [PATCH] Bug 36433: Plugin hook elasticsearch_to_document Add a new hook elasticsearch_to_document in order to allow completing the 'document' to be sent to Elasticsearch. Usage example: (1) add new search fields, (2) normalize/sanitize existing fields, (3) use id fields to retrieve info via web services in other repositories (say VIAF), (4) download file referenced in a field, and index its content. To test: 1. Apply the unit tests patch, and run it: prove t/db_dependent/Koha/Plugins/Biblio_and_Items_plugin_hooks.t => FAIL: Tests fail! The hook is not implemented so the desired 2. Apply this patch, and then repeat 1: => SUCCESS: It works! --- Koha/SearchEngine/Elasticsearch.pm | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/Koha/SearchEngine/Elasticsearch.pm b/Koha/SearchEngine/Elasticsearch.pm index 3f26cbc027..d38b910b1a 100644 --- a/Koha/SearchEngine/Elasticsearch.pm +++ b/Koha/SearchEngine/Elasticsearch.pm @@ -794,6 +794,15 @@ sub marc_records_to_documents { } } + Koha::Plugins->call( + 'elasticsearch_to_document', + { + index => $self->index, + record => $record, + document => $record_document, + } + ); + push @record_documents, $record_document; } return \@record_documents; -- 2.34.1