curiousgeorge
curiousgeorge

Reputation: 121

Python JSON - Elasticsearch - [_na] query malformed, must start with start_object

I am trying to duplicate the following json params in a Python post request:

enter image description here

This is what I have in my dictionary:

payload = {
           'match':{'situs.state':'AL'},
           'notMatch':{},
           'page':1,
           'range':{
                   'loanAmount':[
                                 {
                                  'gte':None,
                                  'lte':10000000
                                 }
                                ]
                    },
            'size':100
          }

I then pass this dictionary into my post request with json.dumps so it gets converted to json and sent with the post request.

data = json.dumps(payload)

However, nothing works as I get the following error:

{"type":"Elasticsearch","message":"[parsing_exception] [_na] query malformed, must start with start_object, with { line=1 & col=119 }","path":"/some_path","query":{"size":100,"from":0},"statusCode":400,"body":{"error":{"root_cause":[{"type":"parsing_exception","reason":"[_na] query malformed, must start with start_object","line":1,"col":119}],"type":"parsing_exception","reason":"[_na] query malformed, must start with start_object","line":1,"col":119},"status":400}}

Where am I going wrong here?

Upvotes: 0

Views: 1598

Answers (1)

Val
Val

Reputation: 217424

The range part should be like this:

     'range':{
          'loanAmount':{
              'gte':None,
              'lte':10000000
          }
     },

Upvotes: 2

Related Questions