# Store directory tree of files in ES

**URL:** <https://discuss.elastic.co/t/store-directory-tree-of-files-in-es/148164>\
**Category:** Elasticsearch\
**Created:** [September 11, 2018, 3:05pm UTC](https://discuss.elastic.co/t/store-directory-tree-of-files-in-es/148164 "2018-09-11T15:05:53Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![TimWard](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/timward/32/19574_2.png) [@TimWard](https://discuss.elastic.co/u/TimWard)\
**Post date:** [September 11, 2018, 3:05pm UTC](https://discuss.elastic.co/t/store-directory-tree-of-files-in-es/148164/1 "2018-09-11T15:05:53Z")

</div>

Suppose I have a directory tree of a modest number of small text files (where "modest" is currently hundreds, won't ever be more than tens of thousands) and "small" is hundreds of bytes, won't ever be more than thousands. These files (both the set of files that exist and their contents) will change occasionally rather than frequently.

We would like to store these files in a database keyed by path name rather than as files in a filing system. We happen to have ES in use in the project so that's the most convenient database to use.

The main operation is to find a file by its path, which the application will have in "some/path/components.ext" form. Other operations needed are

- Copy an existing directory tree into ES
- Dump out the data from ES into a directory tree
- Allow a use to edit individual files

So I can use a single index for this, with the \_id being the path.

Getting a record is

> GET indexname/\_doc/some%2Fpath%2Fcomponents.ext

Allowing a user to edit the occasional individual record is telling them how to use Kibana (the users are already used to this).

Loading from and dumping to a directory tree is a couple of tedious but straightforward Python scripts.

OK? Have I missed anything? Is that the right URL encoding? Has anyone done this? Feel like giving away your Python scripts? 🤣

---

<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:** [September 11, 2018, 3:39pm UTC](https://discuss.elastic.co/t/store-directory-tree-of-files-in-es/148164/2 "2018-09-11T15:39:05Z")

</div>

Would that help?

[http://david.pilato.fr/blog/2015/12/10/building-a-directory-map-with-elk/](http://david.pilato.fr/blog/2015/12/10/building-a-directory-map-with-elk/)

---

<div class="post-metadata">

**Author:** ![TimWard](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/timward/32/19574_2.png) [@TimWard](https://discuss.elastic.co/u/TimWard)\
**Post date:** [September 11, 2018, 3:59pm UTC](https://discuss.elastic.co/t/store-directory-tree-of-files-in-es/148164/3 "2018-09-11T15:59:08Z")

</div>

What fun! - too clever for what I need though (and turns out the Python scripts are more trivial than I thought, and that the URL encoding does seem to work exactly like that)

---

<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:** [October 9, 2018, 3:59pm UTC](https://discuss.elastic.co/t/store-directory-tree-of-files-in-es/148164/4 "2018-10-09T15:59:23Z")

</div>

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