0

i have a lot of JSON documents with this structure :

"positions": [
    {
      "millis": 12959023,
      "lat": 49.01525113731623,
      "lon": 2.4971945118159056,
      "rawX": -3754,
      "rawY": 605,
      "rawVx": 0,
      "rawVy": 0,
      "speed": 9.801029291617944,
      "accel": 0.09442740907572084,
      "grounded": true
    },
    {
      "millis": 12959914,
      "lat": 49.01536940596998,
      "lon": 2.4967825412750244,
      "rawX": -3784,
      "rawY": 619,
      "rawVx": -15,
      "rawVy": 7,
      "speed": 10.841861737855924,
      "accel": -0.09534648619563282,
      "grounded": true
    }
...
}

i'm trying to map this JSON document with Elasticsearch by introducing a geo_point field to get document like the one below :

"positions": [
        {
          "millis": 12959023,
          "location" : {
              "lat": 49.01525113731623,
              "lon": 2.4971945118159056,
           }          
          "rawX": -3754,
          "rawY": 605,
          "rawVx": 0,
          "rawVy": 0,
          "speed": 9.801029291617944,
          "accel": 0.09442740907572084,
          "grounded": true
        },
    ...
    }

PS : these documents are offered by an API.

Thanks

1
  • How are you loading your documents into ES? Probably, Logstash would help in creating that geo_point field, or if you're using ES5 you can use a pipeline/processor to achieve the same thing. Commented Dec 8, 2016 at 5:42

2 Answers 2

2

You could do something like this:

curl -XPUT 'http://localhost:9200/<indexname>/positions/_mapping' -d @yourjsonfile.json

Hope this SO helps!

Sign up to request clarification or add additional context in comments.

1 Comment

If you get an error: "error":"Content-Type header [application/x-www-form-urlencoded] is not supported" then adding -H "Content-Type: application/json" might help
0

If you can't modify the source, you need to pre-process your document before it gets indexed into elasticsearch.

  • If you are using elasticsearch < 5.0, you can use logstash and the mutate filter.
  • If you are using elasticsearch >= 5.0 (my advice), use an ingest pipeline and the rename processor.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.