因此,我在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)
...
>>>
所以,正如你所看到的,它无法找到任何东西。我不知道我做错了什么。