elasticsearch set sort order using querystring

后端 未结 2 443
半阙折子戏
半阙折子戏 2021-02-05 02:36

I have the following simple elastisearch query:

http://localhost:9200/apn/presupuesto/_search?q=subcuenta:penal&sort=anio

And it works fine

相关标签:
2条回答
  • 2021-02-05 02:46

    To answer opensas question

    elasticsearch set sort order using querystring

    this feature is called as multilevel sorting.

    Example query is

    GET /_search
    {
        "query" : {
            "filtered" : {
                "query":   { "match": { "tweet": "manage text search" }},
                "filter" : { "term" : { "user_id" : 2 }}
            }
        },
        "sort": [
            { "date":   { "order": "desc" }},
            { "_score": { "order": "desc" }}
        ]
    }
    

    Order is important. Results are sorted by the first criterion first. Only results whose first sort value is identical will then be sorted by the second criterion, and so on. http://www.elasticsearch.org/guide/en/elasticsearch/guide/current/_sorting.html#_multilevel_sorting

    0 讨论(0)
  • 2021-02-05 03:07

    Try sort=anio:desc.

    See search API - uri request for a list of parameters.

    0 讨论(0)
提交回复
热议问题