欢迎投稿

今日深度:

python elasticsearch 入门教程(四)分析聚合,

python elasticsearch 入门教程(四)分析聚合,


from datetime import datetime
from elasticsearch import Elasticsearch
es = Elasticsearch()

doc = {
    'author': 'kimchy',
    'text': 'Elasticsearch: cool. bonsai cool.',
    'timestamp': datetime.now(),
}
res = es.index(index="test", doc_type='tweet', id=1, body=doc)
print(res['result'])

index = "test"

query = {"aggs":{"all_times":{"terms":{"field":"@timestamp"}}}}
resp = es.search(index, body=query)
total = resp['hits']['total']

www.htsjk.Com true http://www.htsjk.com/Elasticsearch/24755.html NewsArticle python elasticsearch 入门教程(四)分析聚合, from datetime import datetimefrom elasticsearch import Elasticsearches = Elasticsearch()doc = { 'author' : 'kimchy' , 'text' : 'Elasticsearch: cool. bonsai cool.' , 'timestamp' : datetim...
相关文章
    暂无相关文章
评论暂时关闭