Hi I have a mapping with geopoints, and I would like to query all the items that have a location. is there any way to search results that have geopoint and skip items without geopoints ?
thanks
Hi I have a mapping with geopoints, and I would like to query all the items that have a location. is there any way to search results that have geopoint and skip items without geopoints ?
thanks
I don't know if this counts as a real solution , but I'm quering
"geo_distance":{"location":{"lat":0,"lon":0},"distance":"1000000000000000mi"}
I suppose that would be a better alternatives to tackle this
Can you just check if the field location.lat actually exists with the exist
query?
Hi , I've tried these two queries, both return empty results.
'{"query":{"exists":{"field":"location.accuracy"}}}'
=>
'{"query":{"bool":{"must":[{"exists":{"field":"location.accuracy"}}]}}}'
=>
Is accuracy
an existing field?
What is your mapping?
yes, I've also done the same query with lat / lng and got the same results
the location field mapping is a :
"location": {
"type": "geo_point"
},
I don't see in this mapping any field named location.accuracy
.
This example works well for me:
DELETE test
PUT test
{
"mappings": {
"_doc": {
"properties": {
"location": {
"type": "geo_point"
}
}
}
}
}
PUT test/_doc/1
{
"foo": "bar",
"location": [ 0.0, 0.0 ]
}
PUT test/_doc/2
{
"foo": "bar",
"location": {
"lat": 0.0,
"lon": 0.0
}
}
PUT test/_doc/3
{
"foo": "bar"
}
GET test/_search
{
"query": {
"exists": {
"field": "location"
}
}
}
It gives:
{
"took" : 13,
"timed_out" : false,
"_shards" : {
"total" : 5,
"successful" : 5,
"skipped" : 0,
"failed" : 0
},
"hits" : {
"total" : 2,
"max_score" : 1.0,
"hits" : [
{
"_index" : "test",
"_type" : "_doc",
"_id" : "2",
"_score" : 1.0,
"_source" : {
"foo" : "bar",
"location" : {
"lat" : 0.0,
"lon" : 0.0
}
}
},
{
"_index" : "test",
"_type" : "_doc",
"_id" : "1",
"_score" : 1.0,
"_source" : {
"foo" : "bar",
"location" : [
0.0,
0.0
]
}
}
]
}
}
Oh! I didn't try "location" only field, it just work!
thanks!
This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.
© 2020. All Rights Reserved - Elasticsearch
Apache, Apache Lucene, Apache Hadoop, Hadoop, HDFS and the yellow elephant logo are trademarks of the Apache Software Foundation in the United States and/or other countries.