Geo Point


(Tal) #1

Hi
I'm new in ES.
I have Json like this
{"altitde": 10972.8,"callsign": "","heading": 191.74,"icao24": "842194","latitde": 36.666,"longitde":35.222,"on_grond": true,"origin_contry": "Japan","sensors": false,"time_position": 0,"time_velocity": 1499164181,"velocity": 199.67,"vertical_rate": 0,"location": [40.0233,80.3336]}
I can fit it as I wish but right now I try to map like this
},
"geoip" : {
"type" : "object",
"dynamic": true,
"properties" : {
"location" : { "type" : "geo_point" },
"latitude" : { "type" : "half_float" },
"longitude" : { "type" : "half_float" }
}
Please advise how can I fit the Json to mapping or mappint to this Json
Thanks
Tal


(Peter Dyson) #2

Hi Tal,

For that location field, you'll want to map it as a geo_point like this:

    "location": {
      "type": "geo_point"
    }

So for example:

PUT /test-geo/
{
  "mappings": {
    "doc": {
      "properties": {
        "callsign": {
          "type": "text",
          "fields": {
            "keyword": {
              "type": "keyword",
              "ignore_above": 256
            }
          }
        },
        "heading": {
          "type": "float"
        },
        "icao24": {
          "type": "text",
          "fields": {
            "keyword": {
              "type": "keyword",
              "ignore_above": 256
            }
          }
        },
        "latitde": {
          "type": "float"
        },
        "longitde": {
          "type": "float"
        },
        "on_grond": {
          "type": "boolean"
        },
        "origin_contry": {
          "type": "text",
          "fields": {
            "keyword": {
              "type": "keyword",
              "ignore_above": 256
            }
          }
        },
        "sensors": {
          "type": "boolean"
        },
        "time_position": {
          "type": "long"
        },
        "time_velocity": {
          "type": "long"
        },
        "velocity": {
          "type": "float"
        },
        "vertical_rate": {
          "type": "long"
        },
        "location": {
          "type": "geo_point"
        }
      }
    }
  }
}

Then that field will be a geo_point when you index your json into the index, eg:

POST /test-geo/doc/
{
  "altitde": 10972.8,
  "callsign": "",
  "heading": 191.74,
  "icao24": "842194",
  "latitde": 36.666,
  "longitde": 35.222,
  "on_grond": true,
  "origin_contry": "Japan",
  "sensors": false,
  "time_position": 0,
  "time_velocity": 1499164181,
  "velocity": 199.67,
  "vertical_rate": 0,
  "location": [
    40.0233,
    80.3336
  ]
}

(Tal) #3

Hi Peter
Thanks a lot.
It works !!


(system) #4

This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.