# Make a filter on sub folders - I want to see the files inside the sub folder I selected

**URL:** <https://discuss.elastic.co/t/make-a-filter-on-sub-folders-i-want-to-see-the-files-inside-the-sub-folder-i-selected/191536>\
**Category:** Elasticsearch\
**Created:** [July 21, 2019, 7:53pm UTC](https://discuss.elastic.co/t/make-a-filter-on-sub-folders-i-want-to-see-the-files-inside-the-sub-folder-i-selected/191536 "2019-07-21T19:53:54Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![manideep](https://avatars.discourse-cdn.com/v4/letter/m/6a8cbe/32.png) [@manideep](https://discuss.elastic.co/u/manideep)\
**Post date:** [July 21, 2019, 7:53pm UTC](https://discuss.elastic.co/t/make-a-filter-on-sub-folders-i-want-to-see-the-files-inside-the-sub-folder-i-selected/191536/1 "2019-07-21T19:53:54Z")

</div>

Dear Community,

I am a week old to Elasticsearch and trying to achieve a solution.

I have a folder say test with files and sub folders inside it.

test - folder  
test1 - sub folder  
test2 - sub folder  
test3 - sub folder

I now want to make all test1, test2, test3, as values in a filed and make it searchable. So, I am trying to make the sub folders as filter values.

PS: I have indexed my root folder using fscrawler.

any help would be appreciated.

Thanks,  
Manideep

---

<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:** [July 21, 2019, 8:18pm UTC](https://discuss.elastic.co/t/make-a-filter-on-sub-folders-i-want-to-see-the-files-inside-the-sub-folder-i-selected/191536/2 "2019-07-21T20:18:33Z")

</div>

I'm not sure what the question is.

---

<div class="post-metadata">

**Author:** ![manideep](https://avatars.discourse-cdn.com/v4/letter/m/6a8cbe/32.png) [@manideep](https://discuss.elastic.co/u/manideep)\
**Post date:** [July 21, 2019, 8:24pm UTC](https://discuss.elastic.co/t/make-a-filter-on-sub-folders-i-want-to-see-the-files-inside-the-sub-folder-i-selected/191536/3 "2019-07-21T20:24:13Z")

</div>

Hi @dadoonet,

I have a root folder and sub folders inside the root folder. I want to filter on the sub folder to show only content specific to that sub folder.

Does this help?

Thanks,  
Manideep

---

<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:** [July 21, 2019, 8:48pm UTC](https://discuss.elastic.co/t/make-a-filter-on-sub-folders-i-want-to-see-the-files-inside-the-sub-folder-i-selected/191536/4 "2019-07-21T20:48:37Z")

</div>

I guess it is. Look at the documents generated by FSCrawler.  
You can run a search on it which matches any folder you want.

---

<div class="post-metadata">

**Author:** ![manideep](https://avatars.discourse-cdn.com/v4/letter/m/6a8cbe/32.png) [@manideep](https://discuss.elastic.co/u/manideep)\
**Post date:** [July 21, 2019, 8:55pm UTC](https://discuss.elastic.co/t/make-a-filter-on-sub-folders-i-want-to-see-the-files-inside-the-sub-folder-i-selected/191536/5 "2019-07-21T20:55:28Z")

</div>

I have a path (real, virtual), But it is giving me the full path which i don't want.

Can I write a script to extract the folder name from the path?

---

<div class="post-metadata">

**Author:** ![manideep](https://avatars.discourse-cdn.com/v4/letter/m/6a8cbe/32.png) [@manideep](https://discuss.elastic.co/u/manideep)\
**Post date:** [July 22, 2019, 1:50pm UTC](https://discuss.elastic.co/t/make-a-filter-on-sub-folders-i-want-to-see-the-files-inside-the-sub-folder-i-selected/191536/6 "2019-07-22T13:50:00Z")

</div>

Hi @dadoonet

I tried to extract the folder names using painless lang in kibana. however, I cannot use it in search query.

Any leads on how scripted fields can be used in search query?

PS:I cannot the same script in \_source while writing the query. I just want to used the one already created.

Thanks,  
Manideep

---

<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:** [August 19, 2019, 1:59pm UTC](https://discuss.elastic.co/t/make-a-filter-on-sub-folders-i-want-to-see-the-files-inside-the-sub-folder-i-selected/191536/7 "2019-08-19T13:59:13Z")

</div>

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