【发布时间】:2016-06-01 17:41:47
【问题描述】:
我正在研究弹性搜索。我在 elasticsearch 中创建并索引了 json 文件内容。现在正在尝试使用搜索查询搜索文本。当我尝试在 elasticsearch 中执行以下查询时,它不会在结果中返回任何内容。但价值观就在其中。因为我使用 curl 命令检查,所以它返回结果。
我执行了elasticsearch查询命令
ES_HOST = {"host":"xxx.xx.xx.xx","port":"9200"}
ES_INDEX = 'sugan'
ES_TYPE = 'doc'
es = Elasticsearch(hosts=[ES_HOST])
res = es.search(index=ES_INDEX,body={"query":{"match_all":{}}})
when i print **res**, it's response like below
Search Response:'{u'hits': {u'hits': [], u'total': 0, u'max_score': None}, u'_shards': {u'successful': 1, u'failed': 0, u'total': 1}, u'took': 1, u'timed_out': False}'
for hit in result['hits']['hits']:
print "results:"
print (hit["_source"])
它不调用 for 循环。不知道为什么
它不返回任何东西
我执行了curl命令
curl -XGET 'xxx.xx.xx.xx:9200/sugan/_search?'
得到了正确的结果
【问题讨论】:
-
您能否展示您如何在 Python 代码中设置
es客户端?
标签: python elasticsearch