Created
June 8, 2014 19:30
-
-
Save anonymous/3e6aa70bf8b31e8eb345 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
//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] | |
} | |
} | |
} | |
} | |
} | |
} | |
}' | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
N'oublie de mettre un refresh après la dernière opération d'indexation ou ajouter à la fin un
?refresh