I'm having some issues querying geo_distance in my ES index. Here's my mapping:
{
"Event": {
"properties" : {
"docType": {"type": "string", "store":"yes"},
"description" : {"type" : "string", "store" : "yes"},
"title" : {"type" : "string", "store" : "yes"},
"location" : { "type" : "geo_point", "lat_lon":
"true","store":"yes" },
"startTime" : {"type": "date", "store": "yes"},
"tags" : {"type" : "string", "index_name" : "tag"}
}
}
}
I have documents that look like this:
{
"_index" : "syncrswim",
"_type" : "syncrswim",
"_id" : "3e9e9d1f82385af7e01146f8a4063d42",
"_score" : 0.13977994, "_source" : {"docType":"Event",
"location":{"lon":-110.944703,"lat":32.254652},
"lastUpdated":"2012-06-08T04:12:51",
"provider":"eventbrite",
"externalId":"2487867278",
"stopTime":"2016-08-19T23:00:00",
"_rev":"2-4d5ec9d8fe68689d781493e847600baa",
"startTime":"2015-04-26T03:00:00",
"externalUpdatedDate":"2012-06-08T04:12:51",
"title":"Tucson Young Professionals Membership",
"_id":"3e9e9d1f82385af7e01146f8a4063d42",
"description":"Tucson Young Professionals ...",
"venueId":"3e9e9d1f82385af7e01146f8a40642a4"}
When I do a query like this it works fine:
"query": {
"filtered" : {
"query" : {
"query_string" : {
"query" : "Aesop",
"fields" : [ "title", "description" ]
}
},
"filter" : {
"term" : {
"docType" : "event"
}
}
}
}
I have tried this kind of query:
{
"filtered" : {
"query" : {
"query_string" : {
"query" : "Aesop",
"fields" : [ "title", "description" ]
}
},
"filter" : {
"and" : {
"filters" : [ {
"term" : {
"docType" : "event"
}
}, {
"geo_distance" : {
"location" : {
"lat": 32.2217429,
"long" : -110.926479
},
"distance" : "25.0mi"
}
} ]
}
}
}
}
but that returns zero results. I've tried a different query:
{"query" : {"filtered" : {"query" : {"query_string" : {"query" :
"annual","fields" : [ "title", "description" ]}},"filter" : {"and" :
{"filters" : [ {"term" : {"docType" : "event"}}, {"geo_distance" :
{"Event.location" : {"lat": 32.2217429,"lon" : -110.926479},"distance"
: "50mi"}} ]}}}}}
Which also returns zero results.
Here is the full mapping as returned through _mapping.
{ "syncrswim" : { "syncrswim" : {
"properties" : {
"_rev" : {
"type" : "string"
},
"address1" : {
"type" : "string"
},
"city" : {
"type" : "string"
},
"description" : {
"type" : "string"
},
"docType" : {
"type" : "string"
},
"externalId" : {
"type" : "string"
},
"externalUpdatedDate" : {
"type" : "date",
"format" : "dateOptionalTime"
},
"lastUpdated" : {
"type" : "date",
"format" : "dateOptionalTime"
},
"links" : {
"dynamic" : "true",
"properties" : {
"image" : {
"type" : "string"
},
"main" : {
"type" : "string"
}
}
},
"location" : {
"dynamic" : "true",
"properties" : {
"lat" : {
"type" : "double"
},
"lon" : {
"type" : "double"
}
}
},
"name" : {
"type" : "string"
},
"postalCode" : {
"type" : "string"
},
"provider" : {
"type" : "string"
},
"startTime" : {
"type" : "date",
"format" : "dateOptionalTime"
},
"state" : {
"type" : "string"
},
"stopTime" : {
"type" : "date",
"format" : "dateOptionalTime"
},
"tags" : {
"type" : "string"
},
"title" : {
"type" : "string"
},
"venueId" : {
"type" : "string"
}
}
},
"Place" : {
"properties" : {
"address1" : {
"type" : "string",
"store" : "yes"
},
"city" : {
"type" : "string",
"store" : "yes"
},
"docType" : {
"type" : "string",
"store" : "yes"
},
"location" : {
"type" : "geo_point",
"lat_lon" : true,
"store" : "yes"
},
"name" : {
"type" : "string",
"store" : "yes"
},
"state" : {
"type" : "string",
"store" : "yes"
}
}
},
"Event" : {
"properties" : {
"description" : {
"type" : "string",
"store" : "yes"
},
"docType" : {
"type" : "string",
"store" : "yes"
},
"location" : {
"type" : "geo_point",
"lat_lon" : true,
"store" : "yes"
},
"startTime" : {
"type" : "date",
"store" : "yes",
"format" : "dateOptionalTime"
},
"tags" : {
"type" : "string",
"index_name" : "tag"
},
"title" : {
"type" : "string",
"store" : "yes"
}
}
}
}
}
Any thoughts?
-warner