No mapping found for field in order to sort on in ElasticSearch

后端 未结 9 1526
天命终不由人
天命终不由人 2020-12-12 18:59

Elasticsearch throws a SearchParseException while parsing query if there are some documents found not containing field used in sort criteria.

9条回答
  •  醉梦人生
    2020-12-12 19:12

    You could also use script which gives you some flexibility:

    "sort" : {
        "_script" : {
            "type" : "number",
            "script" : {
                "lang": "painless",
                "source": "return !doc['price'].empty ? doc['price'].value : 0"
            },
            "order" : "desc"
        }
    }
    

提交回复
热议问题