From ef98fbfb627c12456cf316426cbe2d3d9f1305f9 Mon Sep 17 00:00:00 2001 From: Kevin Carnes Date: Tue, 8 Feb 2022 14:35:18 +0100 Subject: [PATCH] Bug 27770: ES: Deprecated aggregation order key [_term] used, replaced by [_key] Starting in Elasticsearch 6.0 _key should be used instead of _term to order buckets by their term To test: 1) Run prove t/db_dependent/Koha/SearchEngine/Elasticsearch/Search.t 2) If you observe an error about types, apply patch for bug 25669 3) Run prove t/db_dependent/Koha/SearchEngine/Elasticsearch/Search.t 4) Observe if you get a deprecation warning about order key 5) Apply patch 6) Run prove t/db_dependent/Koha/SearchEngine/Elasticsearch/Search.t 7) Observe no deprecation warning about order key 8) Sign off Sponsored-by: Lund University Library Signed-off-by: Victor Grousset/tuxayo Signed-off-by: Fridolin Somers Signed-off-by: Kyle M Hall (cherry picked from commit 2cd93d8ea6cab9ba189fc6946ddf1e1fd3619067) Signed-off-by: Andrew Fuerste-Henry Signed-off-by: Wainui Witika-Park --- Koha/SearchEngine/Elasticsearch/QueryBuilder.pm | 4 ++-- t/db_dependent/Koha/SearchEngine/Elasticsearch/QueryBuilder.t | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/Koha/SearchEngine/Elasticsearch/QueryBuilder.pm b/Koha/SearchEngine/Elasticsearch/QueryBuilder.pm index 86669cee08..321773faf4 100644 --- a/Koha/SearchEngine/Elasticsearch/QueryBuilder.pm +++ b/Koha/SearchEngine/Elasticsearch/QueryBuilder.pm @@ -543,8 +543,8 @@ sub _build_scan_query { $index => { terms => { field => $index . '__facet', - order => { '_term' => 'asc' }, - include => $self->_create_regex_filter($self->_clean_search_term($term)) . '.*' + order => { '_key' => 'asc' }, + include => $self->_create_regex_filter($self->clean_search_term($term)) . '.*' } } }; diff --git a/t/db_dependent/Koha/SearchEngine/Elasticsearch/QueryBuilder.t b/t/db_dependent/Koha/SearchEngine/Elasticsearch/QueryBuilder.t index 1266da5ffe..a6739ad4cf 100644 --- a/t/db_dependent/Koha/SearchEngine/Elasticsearch/QueryBuilder.t +++ b/t/db_dependent/Koha/SearchEngine/Elasticsearch/QueryBuilder.t @@ -499,7 +499,7 @@ subtest 'build_query tests' => sub { $query->{aggregations}{'author'}{'terms'}, { field => 'author__facet', - order => { '_term' => 'asc' }, + order => { '_key' => 'asc' }, include => '[nN][eE][wW].*' }, "scan aggregation request is properly formed" @@ -517,7 +517,7 @@ subtest 'build_query tests' => sub { $query->{aggregations}{'subject'}{'terms'}, { field => 'subject__facet', - order => { '_term' => 'asc' }, + order => { '_key' => 'asc' }, include => '[nN][eE][wW].*' }, "scan aggregation request is properly formed" -- 2.39.5