mirror of
https://github.com/alchemy-fr/Phraseanet.git
synced 2025-10-23 18:03:17 +00:00
Fix elastic search sort query
This commit is contained in:
@@ -552,10 +552,13 @@ class ElasticSearchEngine implements SearchEngineInterface
|
|||||||
private function createSortQueryParams(SearchEngineOptions $options)
|
private function createSortQueryParams(SearchEngineOptions $options)
|
||||||
{
|
{
|
||||||
$sort = [];
|
$sort = [];
|
||||||
|
|
||||||
if ($options->getSortBy() === SearchEngineOptions::SORT_RELEVANCE) {
|
if ($options->getSortBy() === SearchEngineOptions::SORT_RELEVANCE) {
|
||||||
$sort['_score'] = $options->getSortOrder();
|
$sort['_score'] = $options->getSortOrder();
|
||||||
} else {
|
} elseif ($options->getSortBy() === SearchEngineOptions::SORT_CREATED_ON) {
|
||||||
$sort['created_on'] = $options->getSortOrder();
|
$sort['created_on'] = $options->getSortOrder();
|
||||||
|
} else {
|
||||||
|
$sort[sprintf('caption.%s', $options->getSortBy())] = $options->getSortOrder();
|
||||||
}
|
}
|
||||||
|
|
||||||
return $sort;
|
return $sort;
|
||||||
|
@@ -337,11 +337,14 @@
|
|||||||
</div>
|
</div>
|
||||||
|
|
||||||
<span>{{ 'Trier par' | trans }}</span>
|
<span>{{ 'Trier par' | trans }}</span>
|
||||||
<select name="sort" class="input-small">
|
<select name="sort" class="input-medium">
|
||||||
<option value="" {% if app['phraseanet.SE'].getDefaultSort() is empty %}selected="selected default-selection"{% endif %}>{{ "No sort"|trans }}</option>
|
<option value="{{ constant('\\Alchemy\\Phrasea\\SearchEngine\\SearchEngineOptions::SORT_CREATED_ON') }}" {% if app['phraseanet.SE'].getDefaultSort() is empty %}selected="selected default-selection"{% endif %}>{{ "Date Added"|trans }}</option>
|
||||||
|
<option value="{{ constant('\\Alchemy\\Phrasea\\SearchEngine\\SearchEngineOptions::SORT_RELEVANCE') }}" {% if app['phraseanet.SE'].getDefaultSort() is empty %}selected="selected default-selection"{% endif %}>{{ "Relevance"|trans }}</option>
|
||||||
|
<optgroup label="{{ 'By field'|trans }}">
|
||||||
{% for sort in search_datas['sort'] %}
|
{% for sort in search_datas['sort'] %}
|
||||||
<option value="{{ sort.fieldname }}" {% if sort.fieldname == app['phraseanet.SE'].getDefaultSort() %}selected="selected default-selection"{% endif %}>{{ sort.fieldname }}</option>
|
<option value="{{ sort.fieldname }}" {% if sort.fieldname == app['phraseanet.SE'].getDefaultSort() %}selected="selected default-selection"{% endif %}>{{ sort.fieldname }}</option>
|
||||||
{% endfor %}
|
{% endfor %}
|
||||||
|
</optgroup>
|
||||||
</select>
|
</select>
|
||||||
<select name="ord" class="input-medium">
|
<select name="ord" class="input-medium">
|
||||||
{% for ord, ord_name in app['phraseanet.SE'].getAvailableOrder() %}
|
{% for ord, ord_name in app['phraseanet.SE'].getAvailableOrder() %}
|
||||||
|
Reference in New Issue
Block a user