Skip to content

Instantly share code, notes, and snippets.

Created April 12, 2011 22:19
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/916564 to your computer and use it in GitHub Desktop.
Save anonymous/916564 to your computer and use it in GitHub Desktop.
Trouble with geo distance
curl -XPOST 'http://localhost:9200/test2/'
curl -XPOST 'http://localhost:9200/test2/_mapping' -d '
{
"rpl" :{
"properties" : {
"location" : {
"type" : "geo_point"
},
"paused" : { "type" : "boolean" },
"military" : { "type" : "boolean" } ,
"amount": { "type" : "double" },
"testableid" : { "type" : "long" },
"testablename" : { "type" : "string" },
"budgetid" : { "type" : "long" },
"name" : { "type" : "string" },
"id" : { "type" : "long" },
"distanceMin": { "type" : "integer" },
"distanceMax": { "type" : "integer" },
"locationType" : { "type" : "string" }
}
}
}'
curl -XPOST 'http://localhost:9200/test2/2751032' -d '
{
"rpl" : {
"paused" : false,
"military" : false,
"amount" : 921,
"testableid" : 1756431,
"testablename" : "1u1mxsh2",
"budgetid" : 2771030,
"name" : "hxlr4uhk",
"id" : 2751032,
"distanceMin": 0,
"distanceMax": 6371,
"location" : {
"lat" : 34,
"lon" : 118
},
"startdate" : "Apr 12, 2011",
"locationType" : "CAMPUS",
"programIds" : [ 3510112,3510113
],
"programCategoryIds" : [ 3250243,3250242,3250247,3250246
],
"programSubCategoryIds" : [ 3250241,3250240,3250245,3250244
],
"programDegreeIds" : [ 0
],
"programEduLevelIds" : [ 110,109
],
"matchingcriteria" : [
"EDUCATION"
]
}
}'
Run a search with curl
curl -XGET 'http://localhost:9200/test2/rpl/_search' -d @queryPausedOnly.json
queryPausedOnly.json contains:
{"query" : {
"custom_score" : {
"query" : {
"field" : { "paused" : false }
},
"script" :"doc['location'].distance(34,-118) < 100"
}
}}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment