How to search in full folder path?

I used ElasticSeaarch index filename with full path.

for example, c:\dir11\dir12\dir13\dir14\fn11.txt
c:\dir21\dir22\dir23\dir24\fn21.pdf
c:\dir31\dir32\dir33\dir34\fn31.doc
c:\dir41\dir42\dir43\dir44\fn41.ppt

What I want to search not just filename, but partial folder are included, for example, "dir13\dir14\fn11.txt".

Would you please give suggestions how to implement? Thanks in advance.

Welcome !

May be this could be helpful? https://www.elastic.co/guide/en/elasticsearch/reference/current/analysis-pathhierarchy-tokenizer.html

Thanks David. Will try that and get back later

Looks like pathhierarchy generates term from beginning or the end.

Is it possible to search part of path in the middle, for example, \dir33\dir34?

Would creating a custom tokenizer for the field and split on \ work? That would give you ability to search on path components.

1 Like

Thanks Christian.

I think this may work. But because the search can start and end anywhere, so we should generate all combinations, and it will need a lot of space

If you are looking for partial paths I assume they would be in sequence. Could you maybe use a phrase query?

Do you mean
https://www.elastic.co/guide/en/elasticsearch/reference/current/query-dsl-match-query-phrase.html#query-dsl-match-query-phrase?

Will try and get back

Thanks Christian. It works. :slight_smile:

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