我想使用regexp在elasticsearch中搜索,但我必须在我尝试过的短语“http://10.10.100.100/test.txt”中避开caractere专题词:
GET indexname/_search
{
"query": {
"nested": {
"path": "test",
"query": {
"bool": {
"must": [
{
"regexp": {
"test.search1": "http://10.10.100.100.*"
}
},
{
"match": {
"test.search2": "url"
}
}
]
}
}
}
}
}不起作用。
当我将"http://10.10.100.100._“替换为"http._”时,它起作用了,因此我需要转义":“和"//”
如何使用elasticsearch实现这一点
发布于 2021-07-20 09:31:45
弹性搜索保留了很少的特殊特征。他们是,
+ - = && || > < ! ( ) { } [ ] ^ " ~ * ? : \ /为了在查询中使用这些字符,需要使用\对它们进行转义。在您的示例中,您应该使用此字符串进行查询。
"test.search1": "http\:\/\/10.10.100.100.*"而不是这个
"test.search1": "http://10.10.100.100.*" 有关更多信息,请参阅以下文档:https://www.elastic.co/guide/en/elasticsearch/reference/current/query-dsl-query-string-query.html#_reserved_characters
https://stackoverflow.com/questions/68413124
复制相似问题