From 9788a2a81264965374603d5d9d0d708f1bedb389 Mon Sep 17 00:00:00 2001 From: Nicolas Le Goff Date: Tue, 30 Dec 2014 16:46:34 +0100 Subject: [PATCH] Fix elastic search sort query --- .../Phrasea/SearchEngine/Elastic/ElasticSearchEngine.php | 5 ++++- templates/web/prod/index.html.twig | 7 +++++-- 2 files changed, 9 insertions(+), 3 deletions(-) diff --git a/lib/Alchemy/Phrasea/SearchEngine/Elastic/ElasticSearchEngine.php b/lib/Alchemy/Phrasea/SearchEngine/Elastic/ElasticSearchEngine.php index 4a43151f5a..1ba3a76ca6 100644 --- a/lib/Alchemy/Phrasea/SearchEngine/Elastic/ElasticSearchEngine.php +++ b/lib/Alchemy/Phrasea/SearchEngine/Elastic/ElasticSearchEngine.php @@ -552,10 +552,13 @@ class ElasticSearchEngine implements SearchEngineInterface private function createSortQueryParams(SearchEngineOptions $options) { $sort = []; + if ($options->getSortBy() === SearchEngineOptions::SORT_RELEVANCE) { $sort['_score'] = $options->getSortOrder(); - } else { + } elseif ($options->getSortBy() === SearchEngineOptions::SORT_CREATED_ON) { $sort['created_on'] = $options->getSortOrder(); + } else { + $sort[sprintf('caption.%s', $options->getSortBy())] = $options->getSortOrder(); } return $sort; diff --git a/templates/web/prod/index.html.twig b/templates/web/prod/index.html.twig index ff93c1106e..45a8863c35 100644 --- a/templates/web/prod/index.html.twig +++ b/templates/web/prod/index.html.twig @@ -337,11 +337,14 @@ {{ 'Trier par' | trans }} - + + + {% for sort in search_datas['sort'] %} {% endfor %} +