Insert records for parent/child in same index of elastic search

I have created a mapping in Elasticsearch like below

POST /INDEX
{
   "mappings": {
       "properties": {
           "id": {
               "type": "keyword"
           },
           "join_field": {
               "type": "join",
               "relations": {
                   "coverage": "readership"
               }
           }
       }
   }
}

In above mapping "coverage" is parent and "readership" is child.

(2) I am inserting a document into parent (coverage) using below API call .

POST /INDEX
{
    "id": 102,
    "accountId": 102,
    "users": [{
            "id": 199191,
            "name": "user1"
        }, {
            "id": 199192,
            "name": "user2"
        }
    ],
    "join_field": "coverage"
}

(3) I am inserting child record as follows.

PUT INDEX/_doc/102-5001?routing=102&refresh{
    'id': 5001,
    'accountId': 102,
    "contactId": 5000,
    "reportId": 2,
    "click": 10,
    "view": 2,
    "date": "12-10-1995",
    "join_field": {
        "name": "readership",
        "parent": 102
    }
}

Question. How can i achieve this using logstash input and output plugins.

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