1、导入es的python库
from elasticsearch import Elasticsearch
from elasticsearch.helpers import bulk
from elasticsearch import helpers
import pandas as pd
import os
2、连接es
es = Elasticsearch(hosts="http://192.168.194.16:9200/",timeout=30, max_retries=10, retry_on_timeout=True)
query_body = {
"query":{
"match_all":{}
}
}
3、查询数据(search默认返回1000行数据,可以通过参数size指定返回记录数。但es默认返回10000行。此时需要设置max_result_window参数)。
# 设置某个index的max_result_window
curl -XPUT http://localhost:9200/elastic_segment-20211201/_settings -H "Content-Type:application/json" -d '{"index":{"max_result_window":100000}}'
#设置所有index的max_result_window
curl -XPUT http://localhost:9200/_all/_settings -H "Content-Type:application/json" -d '{"inde