Skip to content

Instantly share code, notes, and snippets.

Created June 8, 2014 19:30
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 anonymous/3e6aa70bf8b31e8eb345 to your computer and use it in GitHub Desktop.
Save anonymous/3e6aa70bf8b31e8eb345 to your computer and use it in GitHub Desktop.
//clear previous data
curl -XDELETE 'http://localhost:9200/campaigns'
//mappings
curl -XPUT 'http://localhost:9200/campaigns?pretty=1' -d '
{
"mappings" : {
"campaign" : {
"properties" : {
"location" : {
"type": "geo_shape",
"tree": "quadtree",
"distance_error_pct": 0.0
}
}
}
}
}
'
//insert document 01
curl -XPOST 'http://localhost:9200/campaigns/campaign' -d '{
"_id": { "c_id": "1889"},
"location" : {
"type" : "circle",
"coordinates" : [45.01, 2.26],
"radius" : "9000m"
},
"zonename": "zonename 01"
}'
//insert document 02
curl -XPOST 'http://localhost:9200/campaigns/campaign' -d '{
"_id": { "c_id": "1890"},
"location" : {
"type" : "circle",
"coordinates" : [45.011, 2.261],
"radius" : "9000m"
},
"zonename": "zonename 02"
}'
//insert document 03
curl -XPOST 'http://localhost:9200/campaigns/campaign' -d '{
"_id": { "c_id": "1891"},
"location" : {
"type" : "circle",
"coordinates" : [45.01, 2.26],
"radius" : "9000m"
},
"zonename": "zonename 03"
}'
// Attempt 1 of search - No results even with changin the radius and relation to "within"
curl -XGET 'localhost:9200/campaigns/campaign/_search' -d '{
"query":{
"filtered": {
"query": {
"match_all": {}
},
"filter": {
"geo_shape": {
"location": {
"relation": "intersects",
"shape": {
"type": "circle",
"coordinates" : [45.01001, 2.26],
"radius":"1m"
}
}
}
}
}
}
}'
// Attempt 1 of search - No results even with changin the radius and relation to "within"
curl -XGET 'localhost:9200/campaigns/campaign/_search' -d '{
"query":{
"filtered": {
"query": {
"match_all": {}
},
"filter": {
"geo_shape": {
"location": {
"relation": "intersects",
"shape": {
"type": "point",
"coordinates" : [45.01001, 2.26]
}
}
}
}
}
}
}'
@dadoonet
Copy link

dadoonet commented Jun 8, 2014

N'oublie de mettre un refresh après la dernière opération d'indexation ou ajouter à la fin un

?refresh

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