python - Elasticsearch - search if tags contains values in a list -
is possible query records 2 different tags have values in specified list?
matches_list = ["4000000031265595", "4000000031265596", "4000000030004305", "4000000029975772"]
query = { "query": { "bool": { "must": [ {"match": {"id_1": matches_list}}, {"match": {"id_2": matches_list}} ] } } } the above returns: elasticsearch.exceptions.transporterror: transporterror(500, u'illegal_state_exception', u"can't text on start_array @ 1:57")
update
error when using large list:
file "/usr/local/lib/python2.7/site-packages/elasticsearch/connection/http_urllib3.py", line 128, in perform_request self._raise_error(response.status, raw_data) file "/usr/local/lib/python2.7/site-packages/elasticsearch/connection/base.py", line 122, in _raise_error raise http_exceptions.get(status_code, transporterror)(status_code, error_message, additional_info) elasticsearch.exceptions.requesterror: transporterror(400, u'search_phase_execution_exception', u'failed create query: {\n "bool" : {\n "must" : [\n {\n "terms" : {\n "id_1" : list in here ],\n "boost" : 1.0\n }\n }\n ],\n "disable_coord" : false,\n "adjust_pure_negative" : true,\n "boost" : 1.0\n }\n}')
the match query doesn't work arrays single string input. use terms instead:
query = { "query": { "bool": { "must": [ {"terms": {"id_1": matches_list}}, {"terms": {"id_2": matches_list}} ] } } }
Comments
Post a Comment