我有一个在弹性搜索中编写的json查询。它也有一个SQL API。我如何在python中运行代码以获得相同的结果。我能够在python中运行其他json查询(不使用sql)。
# This works fine in kibana console. but i am trying to figure out how to
# run this in python. In kibana, I imported the sql api
{
"query":"""
SELECT SCORE(), NAME, ID
FROM index\n Where QUERY(\"houston\")\n
ORDER BY SCORE() DESC"""
}
# Here is the format of the code that works
from datetime import datetime
import requests
from elasticsearch import Elasticsearch
es=Elasticsearch (['localhost'], port=9200)
q={
"query": {
"match": {
"NAME": "texaco"
}
}
}
es.search(body=q)
预期的输出是名称,id和score()的表