From 1dc3a31ee56c7dcc10abc8b081f56a06eebe160f Mon Sep 17 00:00:00 2001 From: Nick Clemens Date: Fri, 3 Oct 2025 12:59:57 +0000 Subject: [PATCH] Bug 39630: WIP - Index 'Date' fields as a date type in Elasticsearch This patch adds a 'date' format to the field_config and makes sure this is used for fields marked as Date in the ES config Currently 'Date' fields are indexed as standard and get keyword and text variations in ES - these field types cannot be used for range searching, so, will we try to build range queries correctly, they will not return results. TO DO: We currently escape the brackets when building a range query, i.e.: '(date-of-acquisition:\\[2015-01-05 2016-01-05\\])' This does not work, we need to pass the brackets as brackets to allow ranges to work correctly --- Koha/SearchEngine/Elasticsearch.pm | 2 ++ admin/searchengine/elasticsearch/field_config.yaml | 2 ++ 2 files changed, 4 insertions(+) diff --git a/Koha/SearchEngine/Elasticsearch.pm b/Koha/SearchEngine/Elasticsearch.pm index 53afa2929d0..2abd8f1eb38 100644 --- a/Koha/SearchEngine/Elasticsearch.pm +++ b/Koha/SearchEngine/Elasticsearch.pm @@ -215,6 +215,8 @@ sub get_elasticsearch_mappings { $es_type = 'integer'; } elsif ( $type eq 'isbn' || $type eq 'stdno' ) { $es_type = 'stdno'; + } elsif ( $type eq 'date' ) { + $es_type = 'date'; } elsif ( $type eq 'year' ) { $es_type = 'year'; } elsif ( $type eq 'callnumber' ) { diff --git a/admin/searchengine/elasticsearch/field_config.yaml b/admin/searchengine/elasticsearch/field_config.yaml index 41adcef7ed8..b94dd190765 100644 --- a/admin/searchengine/elasticsearch/field_config.yaml +++ b/admin/searchengine/elasticsearch/field_config.yaml @@ -21,6 +21,8 @@ search: boolean: type: boolean null_value: false + date: + type: date integer: type: integer null_value: 0 -- 2.39.5