I want to search filename from a path in Elasticsearch, but I cannot do it.
I have documents consisting of "name" fields with paths.
Example:
Name
"folder/folder1/test/folder2/folder/"
"folder/folder1/test/folder2/folder/test.png"
When I search for "test" here, everything under the "folder/folder1/test/" folder comes up. Likewise, when I search for "es", everything under "folder/folder1/test/" comes up. I need to be able to search in the subdirectory. For example, the expression "es" appears in "test.png".
The methods I tried are tokenizer, path hierarchy, path hierarchy reversed.
My index is like this
"name": {
"type": "text",
"fields": {
"keyword": {
"type": "keyword",
"ignore_above": 256
},
"tokenizer": {
"type": "text",
"analyzer": "my_analyzer"
},
"tree": {
"type": "text",
"analyzer": "custom_path_tree"
},
"tree_reversed": {
"type": "text",
"analyzer": "custom_path_tree_reversed"
}
}
}
Analyzers are like this:
"analyzer": {
"custom_path_tree_reversed": {
"tokenizer": "custom_hierarchy_reversed"
},
"autocomplete": {
"filter": [
"lowercase",
"autocomplete_filter"
],
"type": "custom",
"tokenizer": "standard"
},
"custom_path_tree": {
"tokenizer": "custom_hierarchy"
},
"my_analyzer": {
"tokenizer": "my_tokenizer"
}
},
"tokenizer": {
"custom_hierarchy": {
"type": "path_hierarchy",
"delimiter": "/"
},
"my_tokenizer": {
"type": "standard",
"max_token_length": "30"
},
"custom_hierarchy_reversed": {
"reverse": "true",
"type": "path_hierarchy",
"delimiter": "/"
}
}