Reputation: 429
I am using elasticsearch 7 and I am trying to build up a search request in this way:
{
"query": {
"prefix": {
"document": {
"value": "/home/myfolder"
}
}
}
}
in order to find all folders starting with /home/myfolder ("document" element is stored like a path "/home/myfolder/file.txt". I am trying many ways but I didn't found any way to escape properly "/" character. In other links, people suggested to use "\/home/myfolder" or "/home/myfolder" but it does not work.
many thanks for any help
Upvotes: 0
Views: 104
Reputation: 5135
Since you are trying to match with the /
use .keyword
as below.
{
"query": {
"prefix": {
"document.keyword": {
"value": "/home/myfolder"
}
}
}
}
This is because when you dont use keyword, you are trying to match against an analyzed field and by default it removes the /
.
Try running this and see how it breaks at each slash (/
) to create the inverted index.
POST /_analyze
{
"text" :"/home/myfolder/document.txt"
}
Upvotes: 2