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
Post a Comment