#导入相关数据
import tushare as ts
import pandas as pd
#import elasticsearch as es
from datetime import datetime
from elasticsearch import Elasticsearch
df=ts.get_hist_data('000001')
#print(df)
df1=df.iloc[:10]
es = Elasticsearch()
for k in df1.index:
a=df1.loc[k]
b=dict(a)
res = es.index(index=str(k), doc_type='stock', id=1, body=b)
#res = es.get(index="2018-07-31", doc_type='stock', id=1)
res1 = es.search(index="2018-07-31", body={"query": {"match_all": {}}})
print( res1['hits']['hits'])
for hit in res1['hits']['hits']:
print( hit["_source"])
转载于:https://www.cnblogs.com/luoganttcc/p/10525341.html