ES数据导出

#!/bin/sh

vin="
LFBGE3067LJD10854
"
for i in $vin
do

# 查询语句
searchbody=`cat << EOF
{"query":{"bool":{"must":[{"match":{"vin":"$i"}}],"must_not":[],"should":[]}},"from":0,"size":25000,"sort":[],"aggs":{}}
EOF`

index=s2-drive.behavior2023
endpoint="http://10.120.48.17:9200/"
outputpath=/root/20230710/$i.json

# --input 指定来源
# --output 导出的路径(如果以 csv 结尾,则会自动保存为 csv 格式)
# --quiet 不输出任何日志信息
# --scrollTime 用来指定每次滚动查询的时间间隔(当我们需要从 elasticsearch 中检索大量数据时,通常需要使用滚动查询来避免一次性检索过多数据导致内存溢出或性能下降的问题)
# --limit 指定每次滚动查询的文档数量
# --noRefresh 禁用索引的自动刷新功能(当需要执行大量索引操作时,如果每次操作都会自动刷新索引,将导致性能下降)
# --maxRows 指定每次滚动查询的最大文档数量
# --concurrency 并发执行的数量
# --transform 对结果进行转换(如提取特定字段、转换数据格式等)
# --searchBody 查询语句
elasticdump --input="$endpoint/$index" \
  --output=$outputpath \
  --quiet --scrollTime=30m --limit=10000 --noRefresh --maxRows=1000000 \
  --concurrency=2 \
  --searchBody "$searchbody"

done

 

发表回复

您的电子邮箱地址不会被公开。 必填项已用*标注