# How can i put an xml file into elasticsearch by spring data elasticseach

**URL:** <https://discuss.elastic.co/t/how-can-i-put-an-xml-file-into-elasticsearch-by-spring-data-elasticseach/184860>\
**Category:** Elasticsearch\
**Created:** [June 9, 2019, 1:44am UTC](https://discuss.elastic.co/t/how-can-i-put-an-xml-file-into-elasticsearch-by-spring-data-elasticseach/184860 "2019-06-09T01:44:23Z")\
**Posts on this page:** 12\
**Page:** 1

<div class="post-metadata">

**Author:** ![leyla1](https://avatars.discourse-cdn.com/v4/letter/l/41988e/32.png) [@leyla1](https://discuss.elastic.co/u/leyla1)\
**Post date:** [June 9, 2019, 1:44am UTC](https://discuss.elastic.co/t/how-can-i-put-an-xml-file-into-elasticsearch-by-spring-data-elasticseach/184860/1 "2019-06-09T01:44:23Z")

</div>

hi,  
i'm new in elasticsearch, i tried to load xml file into elasticsearch by logstash, but sometimes it loads and sometimes it doesnt load, that's why decide to use filebeat to load it, it loads the file but the logstash filter doesnt work

finally i decide to use spring data elasticsearch but i dont have any idea how to use it

anybody can help me???

---

<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:** [June 9, 2019, 3:17am UTC](https://discuss.elastic.co/t/how-can-i-put-an-xml-file-into-elasticsearch-by-spring-data-elasticseach/184860/2 "2019-06-09T03:17:40Z")

</div>

It would be better to explain what were the problems you had when using filebeat / logstash for example.

About Spring Data, that's a too vague question and I have no idea what to answer.

You can also look at FSCrawler which supports xml files. [https://fscrawler.readthedocs.io/en/latest/admin/fs/local-fs.html#indexing-xml-docs](https://fscrawler.readthedocs.io/en/latest/admin/fs/local-fs.html#indexing-xml-docs)

---

<div class="post-metadata">

**Author:** ![leyla1](https://avatars.discourse-cdn.com/v4/letter/l/41988e/32.png) [@leyla1](https://discuss.elastic.co/u/leyla1)\
**Post date:** [June 10, 2019, 9:04am UTC](https://discuss.elastic.co/t/how-can-i-put-an-xml-file-into-elasticsearch-by-spring-data-elasticseach/184860/3 "2019-06-10T09:04:15Z")

</div>

when i use filebeat, it load all the document file and put it into one field, the filter doesnt work i dont know why

---

<div class="post-metadata">

**Author:** ![leyla1](https://avatars.discourse-cdn.com/v4/letter/l/41988e/32.png) [@leyla1](https://discuss.elastic.co/u/leyla1)\
**Post date:** [June 10, 2019, 9:09am UTC](https://discuss.elastic.co/t/how-can-i-put-an-xml-file-into-elasticsearch-by-spring-data-elasticseach/184860/4 "2019-06-10T09:09:59Z")

</div>

about the spring i want to load a simple file into elasticsearch by spring-data-elastic , i want that the elasticsearch understand all fields, save every tag as a column of the data base and the data into the tag like an enregistrement

---

<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:** [June 10, 2019, 9:45am UTC](https://discuss.elastic.co/t/how-can-i-put-an-xml-file-into-elasticsearch-by-spring-data-elasticseach/184860/5 "2019-06-10T09:45:24Z")

</div>

> [@leyla1](#):
>
> the filter doesnt work i dont know why

I can't tell without knowing what you did.

---

<div class="post-metadata">

**Author:** ![leyla1](https://avatars.discourse-cdn.com/v4/letter/l/41988e/32.png) [@leyla1](https://discuss.elastic.co/u/leyla1)\
**Post date:** [June 10, 2019, 10:55am UTC](https://discuss.elastic.co/t/how-can-i-put-an-xml-file-into-elasticsearch-by-spring-data-elasticseach/184860/6 "2019-06-10T10:55:06Z")

</div>

filebeats.yml  
filebeat.inputs:

- type: log  
enabled: true  
paths:
  - /var/log/test.xml

#----------------------------- Logstash output --------------------------------  
output.logstash:  
hosts: ["logstash:5044"]

loadxml\_filebeat.conf

input {  
beats{  
port =\> 5044  
}  
}

filter {  
xml {  
store\_xml =\> false  
source =\> "message"  
xpath =\>  
[  
"/xmldata/head1/id/text()", "id",  
"/xmldata/head1/date/text()", "date",  
"/xmldata/head1/key1/text()", "key1"  
]  
}  
}

output {  
elasticsearch {  
index =\> "logstash\_xml\_filebeat"  
hosts =\> "elasticsearch:9200"  
document\_id =\>"%{id}"  
}

}

test.xml

 Value1 Value2 0001 01-01-2016 09:00:00 Value3

---

<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:** [June 10, 2019, 11:45am UTC](https://discuss.elastic.co/t/how-can-i-put-an-xml-file-into-elasticsearch-by-spring-data-elasticseach/184860/7 "2019-06-10T11:45:06Z")

</div>

Please format your code, logs or configuration files using `</>` icon as explained in [this guide](https://discuss.elastic.co/t/about-the-elasticsearch-category/21) and not the citation button. It will make your post more readable.

Or use markdown style like:

````
```
CODE
```

````

This is the icon to use if you are not using markdown format:

 ![image](https://us1.discourse-cdn.com/elastic/original/3X/7/e/7e6e239431ec2d71cbf1beef741f2e93e7cc762c.jpg)

There's a live preview panel for exactly this reasons.

Lots of people read these forums, and many of them will simply skip over a post that is difficult to read, because it's just too large an investment of their time to try and follow a wall of badly formatted text.  
If your goal is to get an answer to your questions, it's in your interest to make it as easy to read and understand as possible.  
Please update your post.

Also tell what is the problem with this? What went wrong, error logs...

---

<div class="post-metadata">

**Author:** ![leyla1](https://avatars.discourse-cdn.com/v4/letter/l/41988e/32.png) [@leyla1](https://discuss.elastic.co/u/leyla1)\
**Post date:** [June 10, 2019, 11:57am UTC](https://discuss.elastic.co/t/how-can-i-put-an-xml-file-into-elasticsearch-by-spring-data-elasticseach/184860/8 "2019-06-10T11:57:07Z")

</div>

```
filebeat.inputs:
- type: log
 enabled: true
paths:
 - /var/log/test.xml

#----------------------------- Logstash output --------------------------------
output.logstash:
hosts: ["logstash:5044"] 

```

logstash config file

```
input {
beats{
port => 5044
}
}

filter {
xml {
store_xml => false
source => "message"
xpath =>
[
"/xmldata/head1/id/text()", "id",
"/xmldata/head1/date/text()", "date",
"/xmldata/head1/key1/text()", "key1"
]
}
}

output {
elasticsearch {
    index => "logstash_xml_filebeat"
    hosts => "elasticsearch:9200"
    document_id =>"%{id}"
}

}
```

---

<div class="post-metadata">

**Author:** ![leyla1](https://avatars.discourse-cdn.com/v4/letter/l/41988e/32.png) [@leyla1](https://discuss.elastic.co/u/leyla1)\
**Post date:** [June 10, 2019, 11:58am UTC](https://discuss.elastic.co/t/how-can-i-put-an-xml-file-into-elasticsearch-by-spring-data-elasticseach/184860/9 "2019-06-10T11:58:33Z")

</div>

```
<xmldata>
 <head1>
  <key1>Value1</key1>
  <key2>Value2</key2>
  <id>0001</id>
  <date>01-01-2016 09:00:00</date>
 </head1>
 <head2>
  <key3>Value3</key3>
 </head2>
</xmldata>
```

---

<div class="post-metadata">

**Author:** ![leyla1](https://avatars.discourse-cdn.com/v4/letter/l/41988e/32.png) [@leyla1](https://discuss.elastic.co/u/leyla1)\
**Post date:** [June 11, 2019, 9:15am UTC](https://discuss.elastic.co/t/how-can-i-put-an-xml-file-into-elasticsearch-by-spring-data-elasticseach/184860/10 "2019-06-11T09:15:08Z")

</div>

@dadoonet??

---

<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:** [June 28, 2019, 11:32am UTC](https://discuss.elastic.co/t/how-can-i-put-an-xml-file-into-elasticsearch-by-spring-data-elasticseach/184860/11 "2019-06-28T11:32:39Z")

</div>

As I wrote:

> Also tell what is the problem with this? What went wrong, error logs...

That could help to give you an answer.  
Also I recommend using the logstash stdout plugin to print how logstash is parsing your data.

---

<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:** [July 26, 2019, 11:32am UTC](https://discuss.elastic.co/t/how-can-i-put-an-xml-file-into-elasticsearch-by-spring-data-elasticseach/184860/12 "2019-07-26T11:32:42Z")

</div>

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