Sunday 30 April 2017

Sorting in ElasticSearch using NodeJS Client

I'm trying to sort the results from a query based on a field, and for some reason, it never sorts properly. Below is the example of the query:

  starting request {
   "method": "POST",
   "path": "/index/library/_search",
   "query": {
      "from": 0,
      "size": 10,
      "sort": "[{\"title\":{\"order\":\"asc\"}}]",
      "q": "\"rules\""
     }
   }

Which generates this URL:

http://localhost:9200/index/library/_search?from=0&size=10&sort=%5B%7B%22title%22%3A%7B%22order%22%3A%22asc%22%7D%7D%5D&q=%22rules%22

I've tried a number of different ways of structuring the sort, but for whatever reason, it never returns in alphabetical order.

Am I structuring the sort portion incorrectly? Or am I missing something?



via Siraris

No comments:

Post a Comment