YousefED / ElasticUI

AngularJS directives for Elasticsearch
http://www.elasticui.com
Other
526 stars 135 forks source link

Sorting of facets #47

Closed hagenbauer closed 9 years ago

hagenbauer commented 9 years ago

Is there a way to have the facets not sorted by number of documents but alphabeticaly?

Regards

Hagen

YousefED commented 9 years ago

Hi! Please refer to the Order part of the relevant aggregation, e.g.: https://www.elastic.co/guide/en/elasticsearch/reference/current/search-aggregations-bucket-terms-aggregation.html

Ryan-Berry commented 9 years ago

Hi @hagenbauer

Did you have any joy with this? I'm trying to sort my facets alphabetically as well but am having trouble.

I've tried something like this

eui-aggregation="ejs.TermsAggregation('country').field('country').size(0).order('country','desc')

But I receive a 500 server error.

Thanks in advance!

hagenbauer commented 9 years ago

@EssentialMusic no, I gave it a try but i was not successfull

YousefED commented 9 years ago

If you debug the network request sent and received from ES (Chrome Inspector -> network tab), I might be able to dig in and help

Ryan-Berry commented 9 years ago

Thanks both for the quick response. I've actually now solved this!

@YousefED I was looking at the network inspector yesterday and got nowhere. Had another look this morning and decided to copy my query into ES-Head to try and debug there and also looking at the ES docs again: https://www.elastic.co/guide/en/elasticsearch/reference/current/search-aggregations-bucket-terms-aggregation.html#search-aggregations-bucket-terms-aggregation-order

Basically, where I had .order('country','desc') I should have been using .order('_term','desc')

Hope this also helps you @hagenbauer