From 1bfcb995554c61adc56391b07c0eb4d9d3a5fdba 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 --- Koha/SearchEngine/Elasticsearch/QueryBuilder.pm | 2 +- t/db_dependent/Koha/SearchEngine/Elasticsearch/QueryBuilder.t | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/Koha/SearchEngine/Elasticsearch/QueryBuilder.pm b/Koha/SearchEngine/Elasticsearch/QueryBuilder.pm index 607634c405..3e2cb1b784 100644 --- a/Koha/SearchEngine/Elasticsearch/QueryBuilder.pm +++ b/Koha/SearchEngine/Elasticsearch/QueryBuilder.pm @@ -643,7 +643,7 @@ sub _build_scan_query { $index => { terms => { field => $index . '__facet', - order => { '_term' => 'asc' }, + 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 2991ee39b6..b4e2de938c 100755 --- a/t/db_dependent/Koha/SearchEngine/Elasticsearch/QueryBuilder.t +++ b/t/db_dependent/Koha/SearchEngine/Elasticsearch/QueryBuilder.t @@ -507,7 +507,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" @@ -525,7 +525,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