Created
June 14, 2022 13:20
-
-
Save mhugo/724320454f14a39ec3809ece5d9e00b4 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 58 shapes | |
# curl "https://public.opendatasoft.com/api/explore/v2.0/catalog/datasets/georef-france-commune-millesime/exports/geojson?select=geo_shape&where=arrdep_code=561&refine=year:2021" -o arrdep561.geojson | |
# 250 shapes | |
# curl "https://public.opendatasoft.com/api/explore/v2.0/catalog/datasets/georef-france-commune-millesime/exports/geojson?select=geo_shape&where=dep_code=56&refine=year:2021" -o dep56.geojson | |
# 1208 shapes | |
# curl "https://public.opendatasoft.com/api/explore/v2.0/catalog/datasets/georef-france-commune-millesime/exports/geojson?select=geo_shape&where=reg_code=53&refine=year:2021" -o reg53.geojson | |
# 34978 shapes - warning too large for a unique http index call | |
# curl "https://public.opendatasoft.com/api/explore/v2.0/catalog/datasets/georef-france-commune-millesime/exports/geojson?select=geo_shape&refine=year:2021" -o fr.geojson | |
INPUTFILE=$1 | |
ES=$2 | |
INDEX=$3 | |
if true; then | |
echo "Create index ..." | |
# Delete index | |
curl -s -XDELETE "${ES}/${INDEX}" -O /dev/null | |
curl -s -XPUT "${ES}/${INDEX}" -H 'Content-Type: application/json' -d '{"mappings":{"properties": {"geoshape": {"type": "geo_shape"}}}}' -O /dev/null | |
# index shapes | |
cat $INPUTFILE | jq -c '.features[]|({"index":{}},{"geoshape":.geometry})' | curl -s -H 'Content-Type: application/x-ndjson' -XPOST "${ES}/${INDEX}/_bulk" -O /dev/null --data-binary @- | |
curl -s -XPOST "${ES}/${INDEX}/_refresh" -O /dev/null | |
fi | |
Q='{"query":{"bool":{"filter":[{"geo_shape":{"geoshape":{"shape":{"type":"Point","coordinates":[-3.383390,47.757460]},"relation": "intersects"}}}]}}}' | |
# search | |
echo "Search ..." | |
TIMEFORMAT=%E | |
time ( | |
for i in {1..1000}; do | |
curl -s -H 'Content-Type: application/json' -XPOST "${ES}/${INDEX}/_search" -O /dev/null -d "$Q" | |
done | |
) | |
# multisearch | |
(for i in {1..50000}; do echo -en "{}\n$Q\n"; done) >q | |
echo "Multisearch ..." | |
time (cat q | curl -s -H 'Content-Type: application/x-ndjson' -XPOST "${ES}/${INDEX}/_msearch" -O /dev/null --data-binary @-) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Typical results on a Linux machine with: