1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49
| ES 游标操作
[root@localhost temp_pcap]# cat test1.sh ES_result_file="ES_result_json" curl -XGET "http://192.168.101.23:9200/aa_0419_dvd_rom_redo_http_n_20180429/_search?pretty&scroll=10m" -d' { "query": { "bool": { "must": [{ "wildcard": { "user-agent.keyword": "*" } }], "must_not": [], "should": [] } }, "from": 0, "size": 10000, "sort": [], "aggs": {} } ' > $ES_result_file
scroll_id=`cat $ES_result_file | grep _scroll_id | awk -F "\"" '{print $4}'`
counter=1 while true do let counter=$counter+1 filename="${ES_result_file}_${counter}" curl -XGET "http://192.168.101.23:9200/_search/scroll?scroll=5m&pretty&scroll_id=$scroll_id" > $filename lines=`cat $filename | wc -l` if [ $lines -lt 20 ] then echo $filename "too short" rm -rf $filename break fi done [root@localhost temp_pcap]# bash test1.sh [root@localhost temp_pcap]# ll total 3.2G -rw-r--r--. 1 root root 14M May 7 11:50 ES_result_json -rw-r--r--. 1 root root 14M May 7 11:50 ES_result_json_2 -rw-r--r--. 1 root root 14M May 7 11:50 ES_result_json_3 -rw-r--r--. 1 root root 14M May 7 11:50 ES_result_json_4 -rw-r--r--. 1 root root 14M May 7 11:50 ES_result_json_5 -rw-r--r--. 1 root root 13M May 7 11:50 ES_result_json_6 -rw-r--r--. 1 root root 901 May 7 11:50 test1.sh
|