First off, after reading the docs it seemed like any document
structured as
{
"location" : {
"lat" : 0,
"lon" : 0,
}
}
Would automatically get mapped as a type : "geo_point".
So my document should be..I tried fixed mapping and dynamic mapping
but no luck. With fixed mapping it doesn't get registered as
geo_point - clearly a failure on my end but I've no idea what.
here is an example document:
{
"rpl_edu" : {
"paused" : false,
"distanceMin": 0,
"distanceMax": 5,
"location" : {
"lat" : 33,
"lon" : -97
}
}
}
And I am trying to do a filter query like so:
{
"query" : {
"filtered" : {
"query" : {
"field" : { "paused" : "false" }
},
"filter" : {
"script" : {
"script" :"doc['location'].distance(34,-118) <
doc['distanceMax'].value"
}
}
}
}
}
If I use dynamic mapping, I get "No field found for [location]". I
have tried using rpl_edu.location, attempting to emulate
'pin.location' from the documentation but no luck. If I use fixed
mapping, it doesn't recognize it as a geo_point even though I think
i've defined it as such.
{
"rpl_edu" : {
"properties" : {
"paused" : { "type" : boolean,"index" : "analyzed" },
"distanceMin": { "type" : integer,"index" : "analyzed" },
"distanceMax": { "type" : integer,"index" : "analyzed" },
"location" : {
"type" : "geo_point",
"index" : "analyzed"
},
}
}
}
I have tried the query under "_all/_search" as well as under the index
directly "/edus/rpl_edu/_search". Tried many things. No idea why ES
won't grok my query.
I have tried the basic filter geo query defined in the doc
(which by the way there is a bug there - missing a comma after
'distance'). Query is here:
{"query": {
"filtered" : {
"query" : {
"field" : { "paused" : false }
},
"filter" : {
"geo_distance" : {
"distance" : "12km",
"location" : {
"lat" : 34,
"lon" : -118
}
}
}
}
}
}
And this is the output:
"QueryParsingException[[rpl_edus] failed to find geo_point field
[location]];"
What am I doing wrong?