Sorting and latest records in ElasticSearch
问题 I've two questions related to ElasticSearch. 1) Is there any way to specify that I want results with specific field sorted in descending order? An equivalt SQL query will be: select * from table1 where a="b" order by myprimarykey desc; 2) How to get first and last(latest) record? 回答1: 1) Elasticsearch has quite sophisticated Sorting API that allows you to control sort order. So, in elasticsearch, an equivalent to your MySql query would look like this: { "query" : { "term" : { "a" : "b" } },