# Storing XML in Elastic Search without analyzing/indexing

**URL:** https://discuss.elastic.co/t/storing-xml-in-elastic-search-without-analyzing-indexing/66857
**Category:** Elasticsearch
**Created:** [November 22, 2016, 12:47pm UTC](https://discuss.elastic.co/t/storing-xml-in-elastic-search-without-analyzing-indexing/66857 "2016-11-22T12:47:36Z")
**Posts on this page:** 6
**Page:** 1

<div class="post-metadata">

### Author: ![jiouser](https://avatars.discourse-cdn.com/v4/letter/j/e99b99/32.png) [@jiouser](https://discuss.elastic.co/u/jiouser)
#### Post date: [November 22, 2016, 12:47pm UTC](https://discuss.elastic.co/t/storing-xml-in-elastic-search-without-analyzing-indexing/66857/1 "2016-11-22T12:47:36Z")

</div>

I need to store the XML document and some information pertaining to this in ES. Basically I dont want the XML to be analyzed/indexed. The additional information for the XML will be stored in the field.  
When the query is fired for the field, I need to get this XML file pertaining to the search output.

How can I store XML file in ES without indexing/analyzing it. I need to store it and get it as it is without no modification whatsoever for handling some failure scenario.  
I am not looking for any additional framework or plugin. Additionally, I don't want to convert XML into JSON as I am not going to index XML.  
XML to be stored as it is in ES and some properties of XML to be stored as field in ES.

How can I achieve this?

---

<div class="post-metadata">

### Author: ![nik9000](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/nik9000/32/44947_2.png) [@nik9000](https://discuss.elastic.co/u/nik9000)
#### Post date: [November 22, 2016, 3:31pm UTC](https://discuss.elastic.co/t/storing-xml-in-elastic-search-without-analyzing-indexing/66857/2 "2016-11-22T15:31:03Z")

</div>

Slap the XML into a json string (you'll have to escape it) and declare that string as [`text`](https://www.elastic.co/guide/en/elasticsearch/reference/current/text.html) but set `index` to `false`.

If you did want to convert the XML to json you could stick it under an object and declare that [`object`](https://www.elastic.co/guide/en/elasticsearch/reference/current/object.html) as [`dynamic=false`](https://www.elastic.co/guide/en/elasticsearch/reference/current/dynamic.html). `dynamic=false` is one of my favorite features because you can add fields to the index that are just stored and Elasticsearch doesn't _do_ anything with them beyond storing them. It takes away that magic "elasticsearch analyzes all the things" feeling but it makes me feel more in control.

---

<div class="post-metadata">

### Author: ![jiouser](https://avatars.discourse-cdn.com/v4/letter/j/e99b99/32.png) [@jiouser](https://discuss.elastic.co/u/jiouser)
#### Post date: [November 23, 2016, 6:29am UTC](https://discuss.elastic.co/t/storing-xml-in-elastic-search-without-analyzing-indexing/66857/3 "2016-11-23T06:29:44Z")

</div>

Hello.  
Is there a way out to store the XML straight into the ES without converting it into a JSON string (by escaping). dynamic=false might not help as I dont wish to parse XMl. I just have to store the XML in the ES with some attributes which are normal key value pair.

---

<div class="post-metadata">

### Author: ![jiouser](https://avatars.discourse-cdn.com/v4/letter/j/e99b99/32.png) [@jiouser](https://discuss.elastic.co/u/jiouser)
#### Post date: [November 23, 2016, 6:32am UTC](https://discuss.elastic.co/t/storing-xml-in-elastic-search-without-analyzing-indexing/66857/4 "2016-11-23T06:32:40Z")

</div>

More so, what if my POJO contains an XML. I mean before writing the data into XML, the information is stored in POJO (a class object).  
Is it possible to store the class object in ES without ES analyzing/indexing it.

---

<div class="post-metadata">

### Author: ![dadoonet](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/dadoonet/32/137187_2.png) [@dadoonet](https://discuss.elastic.co/u/dadoonet)
#### Post date: [November 23, 2016, 8:13am UTC](https://discuss.elastic.co/t/storing-xml-in-elastic-search-without-analyzing-indexing/66857/5 "2016-11-23T08:13:41Z")

</div>

You can may be store it in a field like:

```auto
{
  "xml": "<bla></bla>"
}

```

But whatever happens, you will need to send a JSON document to elasticsearch.

@jprante created an open source project which might help though: [https://github.com/jprante/elasticsearch-xml](https://github.com/jprante/elasticsearch-xml)

---

<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: [December 21, 2016, 8:13am UTC](https://discuss.elastic.co/t/storing-xml-in-elastic-search-without-analyzing-indexing/66857/6 "2016-12-21T08:13:45Z")

</div>

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