Last active
August 29, 2015 14:16
-
-
Save sokil/1e8e309fafa46f85add2 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
#!/bin/sh | |
curl -XDELETE http://localhost:9200/mycol | |
curl -XPOST http://localhost:9200/mycol | |
curl -XPOST http://localhost:9200/mycol/_mapping/mytype -d '{"mytype": {"properties": {"loc": {"type": "geo_point"}}}}' | |
lat=-90; | |
while [ $lat -lt 91 ] | |
do | |
lon=-180; | |
while [ $lon -lt 181 ] | |
do | |
min=0; | |
while [ $min -lt 5 ] | |
do | |
curl -XPOST http://localhost:9200/mycol/mytype -d '{"loc": {"lat": '$lat.$min', "lon": '$lon.$min'}}' > /dev/null 2> /dev/null | |
echo $lat $lon; | |
min=`expr $min + 1` | |
done; | |
lon=`expr $lon + 1` | |
done; | |
lat=`expr $lat + 1` | |
done; |
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
#!/bin/bash | |
lat=`expr $RANDOM / 1000`.`expr $RANDOM / 1000` | |
lon=`expr $RANDOM / 1000`.`expr $RANDOM / 1000` | |
echo Coordinates: $lat $lon | |
curl -XGET 'http://localhost:9200/mycol/_search?pretty' -d '{ | |
"query": { | |
"function_score": { | |
"functions": [ | |
{ | |
"linear": { | |
"loc": { | |
"origin": {"lat": '$lat', "lon": '$lon'}, | |
"offset": "1km", | |
"scale": "50km", | |
"decay": 0.5 | |
} | |
}, | |
"weight": 1 | |
} | |
] | |
} | |
}, | |
"sort": ["_score"], | |
"size": 10 | |
}' |
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
#!/bin/bash | |
lat=`expr $RANDOM / 1000`.`expr $RANDOM / 1000` | |
lon=`expr $RANDOM / 1000`.`expr $RANDOM / 1000` | |
echo Coordinates: $lat $lon | |
curl -XGET 'http://localhost:9200/mycol/_search?pretty' -d '{ | |
"sort": [ | |
{ | |
"_geo_distance": { | |
"loc": { | |
"lat": '$lat', | |
"lon": '$lon' | |
}, | |
"order": "asc", | |
"unit": "km", | |
"mode": "min", | |
"distance_type": "plane" | |
} | |
} | |
], | |
"size": 10 | |
}' |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment