gpt4 book ai didi

regex - 如何在elasticsearch中编写正则表达式,以便为我提供带数字的URL?

转载 作者:行者123 更新时间:2023-12-03 01:31:16 25 4
gpt4 key购买 nike

我正在尝试在与Elastisearch查询DSL一起使用的Kibana中编写查询。基本过滤器如下:

{
"query": {
"match": {
"path": {
"query": "/abc/",
"type": "phrase"
}
}
}
}

现在,我需要编写一个查询,以便它给我“path”的形式为/ abc /(0-9)/。

我尝试了此处提供的引用,但对我而言没有任何意义(我对Elasticsearch不太了解):
https://www.elastic.co/guide/en/elasticsearch/reference/current/query-dsl-regexp-query.html

我想过滤出格式为path = / abc / 12345 /的结果

最佳答案

This RegEx可以帮助您做到这一点:

\x22query\x22:\s\x22(\/.*)\x22

它会创建一个目标捕获组,在该目标捕获组中,您需要的输出是,您可能可以使用$ 1进行调用。

enter image description here

如果愿意,可以在模式中添加其他边界,例如 this RegEx:
\x22query\x22:\s\x22([\/a-z0-9]+)\x22

enter image description here

关于regex - 如何在elasticsearch中编写正则表达式,以便为我提供带数字的URL?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/55897550/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com