【发布时间】:2019-07-24 20:51:39
【问题描述】:
In the official Elasticsearch documentation 上面写着Any reserved character can be escaped with a backslash "\*" including a literal backslash character: "\\"。
你能解释一下为什么要这样查询
{
"query": {
"bool": {
"must": [
{
"regexp": {
"path": ".*test\/test.txt.*"
}
},
{
"match": {
"user_id": 1
}
}
]
}
}
}
找不到这样的索引
{
"_index": "pictures",
"_type": "picture",
"_id": "wiskQ2kBi923Omj4U",
"_score": 1,
"_source": {
"user_id": 1,
"tag": [],
"text": "some text",
"path": "test/test.txt"
}
}
【问题讨论】:
-
你不需要转义
/,是吗? -
@MatBailie 取决于引擎。在某些引擎中,您需要逃脱。但不确定 OP 使用的是哪个引擎
-
能否也添加索引的映射?
-
@NishantSaini 我无法将其粘贴到已编辑的帖子中,因此我将其粘贴在这里pastebin.com/MmwmVDU0
标签: regex elasticsearch indexing elastic-stack elasticsearch-query