1,利用分页,from,to参数,但是当数据量特别大的时候(大约100w),分页是不现实的,排序排不开。
2,利用scan功能。
上 Python代码
from elasticsearch import Elasticsearch
from elasticsearch import helpers es = Elasticsearch(config['es_server']) index_v="teacher-center-single_question_count"
doc_type_v="single_question_count" query={"query" : {"match_all" : {}}} scanResp= helpers.scan(client= es, query=query, scroll= "10m", index= index_v , doc_type=doc_type_v , timeout="10m") for resp in scanResp:
qid = resp['_id']
3,如何取出两个数组中的 不同的部分
def find_diff(a,b): common = list(set(a).intersection(set(b)))
#print common alld = list(set(a).union(set(b)))
#print alld diff = list(set(alld).difference(set(common)))
#print diff return diff