在Elasticsearch python客户端中使用SQL Access



我正在尝试使用python客户端进行弹性搜索,以使用SQL访问进行弹性搜索来查询索引。我想使用sql语法查询索引。我如何指定弹性搜索必须读取SQL语法?

def searchText(text):
t1 = time.time()
es=Elasticsearch([{'host':'localhost','port':9200}])
res =  es.search(index='global_res_todos_acco', size=10000, request_timeout=60,
body={'query':{
"select * from global_res_todos_acco limit 100 where EntityList = " + text
}
}
)
GHList = []
for hit in res['hits']['hits']:
GHList.append(hit['_source']['Geohash7'])
return(GHList)

我在控制台中收到以下错误

类型错误:无法从global_res_todos_acco序列化{'select*,其中EntityList=phuket indian food'}

如果使用Python客户端,则需要使用es.sql.query()函数:

es=Elasticsearch([{'host':'localhost','port':9200}])
es.sql.query(body={'query': 'select * from global_res_todos_acco...'})

最新更新