# How to store XML input to multiples indices

**URL:** <https://discuss.elastic.co/t/how-to-store-xml-input-to-multiples-indices/213271>\
**Category:** Logstash\
**Created:** [December 28, 2019, 11:51pm UTC](https://discuss.elastic.co/t/how-to-store-xml-input-to-multiples-indices/213271 "2019-12-28T23:51:48Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![razimandom](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/razimandom/32/60048_2.png) [@razimandom](https://discuss.elastic.co/u/razimandom)\
**Post date:** [December 28, 2019, 11:51pm UTC](https://discuss.elastic.co/t/how-to-store-xml-input-to-multiples-indices/213271/1 "2019-12-28T23:51:48Z")

</div>

I have a deeply nested XML with few entities that I would to store in XML. Single XML file should be store to multiple indices. But I don't know how to split it to store to multiple indices.

Output from this file, it will create 3 indices:

- Individual
- Address
- Relationships

**Example XML:**

```
<Individual>
    <Id>1</Id>
    <Name>Richard</Name>
    <Age>32</Age>
    <Addresses>
       <Address>
           <Line 1>abc</Line 1>
           <Line 2>def</Line 2>
       </Address>
       <Address>
          <Line 1>123</Line1>
          <Line 2>456</Line2>
       </Address>
    </Addresses>
    <Relationships>
       <Relationship>
          <Id>2</Id>
          <Name>Richard Edward</Name>
          <Type>Brother</Type>
       </Relationship>
       <Relationship>
          <Id>3</Id>
          <Name>Richard Hugo</Name>
          <Type>Brother</Type>
       </Relationship>
    </Relationships>
</Individual>

```

**Sample config:**

input {

```
file {
    path => ["/var/shared_folder/*.xml"]
    start_position => beginning
    tags => ['individual_xml']
    codec => multiline {
        pattern => "<Individual>"
        negate => "true"
        what => "previous"
    }
}

```

}

filter {

```
if 'individual_xml' in [tags] {

    xml {
    source => "message"
    store_xml => "false"
    xpath => ["/Individual/Id/text()","id"]
    xpath => ["/Individual/Name/text()","name"]
    xpath => ["/Individual/Age/text()","age"]
    }

    mutate {
        remove_field => ["message", "xml", "xmldata", "host"]
    }

    mutate {
    convert => { "id" => "string" }
    convert => { "name" => "string" }
    convert => { "age" => "string" }
    }
}

```

}

output {

```
if 'individual_xml' in [tags] {
  elasticsearch {
    hosts => ["localhost:9200"]
    manage_template => false
    index => "individual"
  }
}

```

}

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/elastic/original/3X/1/a/1ac57faf039f6b580b3f104ef42a2a89e41014de.png) [@system](https://discuss.elastic.co/u/system)\
**Post date:** [January 25, 2020, 11:51pm UTC](https://discuss.elastic.co/t/how-to-store-xml-input-to-multiples-indices/213271/2 "2020-01-25T23:51:49Z")

</div>

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