1234567891011121314151617181920212223242526272829 |
- import datetime
- import json
- from elasticsearch import Elasticsearch
- from elasticsearch import helpers
- index_name = 'eip_rec_feed'
- es = Elasticsearch(
- ['http://eip-es-3.mlamp.cn:9200/'],
- http_auth=('recommend', '=FhULOxd'),
- port=9200,
- use_ssl=False
- )
- print("索引情况")
- print(es.cat.indices())
- #
- print("mapping情况")
- res = es.indices.get_mapping(index=index_name)
- print(json.dumps(res, indent=2))
- print("查询情况")
- body = {
- "query": {
- "match_all": {}
- }
- }
- res = es.search(index=index_name, doc_type="_doc", body=body)
- print(json.dumps(res, indent=2))
|