Elasticsearch - python syntax from working curl example -


using curl, following request works:

curl -xget 'localhost:9200/dumperino/_search?pretty' -h 'content-type: application/json' -d' {   "query": {     "bool": {       "should": [         { "match": { "id_1":  "4000000029898186" }},         { "match": { "id_2":  "4000000029898188"   }}       ]     }   } } ' 

i'm trying use elasticsearch via python.

from elasticsearch import helpers es = elasticsearch.elasticsearch() qu={   "query": {     "bool": {       "should": [         { "match": { "id_1":  "4000000029898186" }},         { "match": { "id_2": "4000000029898188"   }}       ]     }   } } result = es.search(index= "dumperino",q=qu) 

error: elasticsearch.exceptions.requesterror: transporterror(400, u'search_phase_execution_exception', u"failed parse query [{'query': {'bool': {'should': [{'match': {'id_1': '4000000029898186'}}, {'match': {'id_2': '4000000029898188'}}]}}}]")

i've used format before, albeit simpler string query before.

what need change in json query elasticsearch parse correctly in python?

please try this: result = es.search(index= "dumperino",body=qu)


Comments

Popular posts from this blog

php - Vagrant up error - Uncaught Reflection Exception: Class DOMDocument does not exist -

vue.js - Create hooks for automated testing -

Add new key value to json node in java -