无法添加或查找添加的内容

时间:2015-06-16 07:19:41

标签: python elasticsearch

因此,我在Python中打开了两个Ubuntu提示。在一个提示中,我这样做:

>>> from elasticsearch import Elasticsearch
>>> import json
>>> db = Elasticsearch([{'host':'localhost','port':9200}])
>>> doc = {'attr_12_':'admin','type':'object_1_','id':'1'}
>>> rs = db.index(index="reestr", doc_type="object_1_", body=doc)
>>> json.dumps(rs)
'{"_type": "object_1_", "_id": "pBZhz5VQTrGIgqYAiKFmTA", "created": true, "_version": 1, "_index": "reestr"}'

然后我转到另一个窗口并执行此操作:

>>> from elasticsearch import Elasticsearch
>>> db = Elasticsearch([{'host':'localhost','port':9200}])
>>> res = db.search(index="reestr",doc_type="object_1_",q={'type':'object_1_'})
>>> for r in res['hits']['hits']:
...     print(r)
...
>>>

所以,正如你所看到的,它无法找到任何东西。我不知道我做错了什么。

0 个答案:

没有答案