es python 400 error

created at 08-20-2021 views: 10

case 1

RequestError(400, u'parsing_exception', u'bool query does not support [sort]')

code:

error format:
{
"query":{
    "bool":{
        "must":{},
        "filter":{},
        "sort":[]
    }
  }
}


right format:
{
"query":{
    "bool":{
        "must":{},
        "filter":{}

    }
  },
  "sort":[]
}

bool query is a compound query method. sort cannot be included in bool query, and sort should be placed on the same layer as query.

Why should the sort parameter be placed in the same layer as the query? Because the sort parameter sorts the results.

case2

RequestError(400, u'parsing_exception', u'[sort] query malformed, no start_object after query name')

From [sort] query malformed, we speculate that there should be a problem with the constructed json format, check the json format

created at:08-20-2021
edited at: 08-20-2021: