Skip to content

Instantly share code, notes, and snippets.

@mhugo
Created June 14, 2022 13:20
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mhugo/724320454f14a39ec3809ece5d9e00b4 to your computer and use it in GitHub Desktop.
Save mhugo/724320454f14a39ec3809ece5d9e00b4 to your computer and use it in GitHub Desktop.
# 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 @-)
@mhugo
Copy link
Author

mhugo commented Jun 14, 2022

Typical results on a Linux machine with:

  • ES 7.10@bdccab7c7a4 on port 9231
  • ES 7.10@31c026f25cc on port 9232
$ ./es710shape_query_perf_regression.sh reg53.geojson http://localhost:9231 reg53
Create index ...
Search ...
7,890
Multisearch ...
6,111

$ ./es710shape_query_perf_regression.sh reg53.geojson http://localhost:9232 reg53
Create index ...
Search ...
7,717
Multisearch ...
10,005

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment