sql
sql copied to clipboard
GeoPoint return [0,0] when input is string
Description of the issue
When select the doc2, the result is 0.
PUT my-index-000001
{
"mappings": {
"properties": {
"location": {
"type": "geo_point"
}
}
}
}
PUT my-index-000001/_doc/1
{
"text": "Geo-point as an object",
"location": {
"lat": 41.12,
"lon": -71.34
}
}
PUT my-index-000001/_doc/2
{
"text": "Geo-point as an object",
"location": {
"lat": "42.12",
"lon": "-72.34"
}
}
POST _opendistro/_sql
{
"query": """
SELECT location FROM my-index-000001
"""
}
{
"schema": [
{
"name": "location",
"type": "object"
}
],
"datarows": [
[
{
"lon": -71.34,
"lat": 41.12
}
],
[
{
"lon": 0.0,
"lat": 0.0
}
]
],
"total": 2,
"size": 2,
"status": 200
}
Expectation
Return the non zero expected value
Root Cause
Elasticsearch support ingest geo-point in five ways. Currently, the query engine use Source filtering to retrieve the field value, the parser can only parse the numeric value.
Solution 1
Considering other methods to retrieve the field value, e.g. Fields
Solution 2
Enhance the ElasticsearchJsonContent to support more format.