elastic / elasticsearch

Free and Open, Distributed, RESTful Search Engine
https://www.elastic.co/products/elasticsearch
Other
69.5k stars 24.6k forks source link

Inconsistency with geo point type in the fields api #72249

Open jdconrad opened 3 years ago

jdconrad commented 3 years ago

I'm seeing an inconsistency in the response of the fields api when I have a geo point mapped as a standard field versus a geo point mapped as a runtime field.

        "fields" : {
          "rgeopoint" : [
            "45.0, 70.49999998882413"
          ],
          "fgeopoint" : [
            {
              "coordinates" : [
                70.5,
                45.0
              ],
              "type" : "Point"
            }
          ]
        }

I produced this response by executing the following curl commands against 8.0:

curl -X PUT "localhost:9200/test/?pretty" -H 'Content-Type: application/json' -d'
{
  "mappings": {
    "properties": {
      "fboolean":  {"type": "boolean"},
      "fdate":     {"type": "date"},
      "fdouble":   {"type": "double"},
      "fgeopoint": {"type": "geo_point"},
      "fip":       {"type": "ip"},
      "fkeyword":  {"type": "keyword"},
      "flong":     {"type": "long"}
    },
    "runtime": {
      "rboolean": {
        "type": "boolean",
        "script": {
          "source": "emit(doc[\"fboolean\"].value)"
        }
      },
      "rdate": {
        "type": "date",
        "script": {
          "source": "emit(doc[\"fdate\"].value.toInstant().toEpochMilli())"
        }
      },
      "rdouble": {
        "type": "double",
        "script": {
          "source": "emit(doc[\"fdouble\"].value)"
        }
      },
      "rgeopoint": {
        "type": "geo_point",
        "script": {
          "source": "emit(doc[\"fgeopoint\"].value.lat, doc[\"fgeopoint\"].value.lon)"
        }
      },
      "rip": {
        "type": "ip",
        "script": {
          "source": "emit(doc[\"fip\"].value)"
        }
      },
      "rkeyword": {
        "type": "keyword",
        "script": {
          "source": "emit(doc[\"fkeyword\"].value)"
        }
      },
      "rlong": {
        "type": "long",
        "script": {
          "source": "emit(doc[\"flong\"].value)"
        }
      }
    }
  }
}
'

curl -X POST "localhost:9200/test/_doc/?pretty" -H 'Content-Type: application/json' -d'
{
  "fdate": "2021-11-15T13:12:00Z",
  "fkeyword": "blah",
  "fboolean": true,
  "fdouble": 1.0,
  "fgeopoint": "45.0,70.5",
  "fip": "127.0.0.1",
  "flong": "-1"
}
'

curl -X GET "localhost:9200/test/_search?pretty" -H 'Content-Type: application/json' -d'
{
  "fields": [
    "fgeopoint",
    "rgeopoint"
  ],
  "_source": false
}
'
elasticmachine commented 3 years ago

Pinging @elastic/es-search (Team:Search)

elasticsearchmachine commented 1 month ago

Pinging @elastic/es-search-foundations (Team:Search Foundations)