gpt4 book ai didi

regex - Kibana : Cannot query with regex having space

转载 作者:行者123 更新时间:2023-12-01 06:34:18 25 4
gpt4 key购买 nike

我有一个领域

author
Jason Pete
Jason Paul
Mike Yard
Jason Voorhies

在 kibana 4.4 我查询为
author:/Jason.*/

所以我得到了所有的记录
Jason Pete
Jason Paul
Jason Voorhies

好的,现在我想做
author:/Jason P.*/

我预计
Jason Pete
Jason Paul

但我明白了
No Records found :(

我的正则表达式有什么问题?有没有另一种方法可以在 Jason 之后指定空格字符?我什至试过
author:/Jason\sP.*/

但仍然没有结果

最佳答案

这是因为您的 author 字段可能已被分析,因此,值 Jason Pete 被标记为两个标记 jasonpete 。因此,不可能查询这两个值。

如果你想改变这种行为,我建议你从 author 字段中创建一个多字段,带有一个 not_analyzed 子字段,如下所示:

curl -XPUT localhost:9200/my_index/_mapping/my_type -d '{
"my_type": {
"properties": {
"author": {
"type": "string",
"fields": { <--- add this section to author your field
"raw": {
"type": "string",
"index": "not_analyzed"
}
}
}
}
}
}'

一旦您的映射更新(确保用您拥有的任何索引和映射类型名称替换 my_indexmy_type),您需要重新索引您的数据,然后您将能够像这样查询 Kibana 中的 author.raw 字段:
author.raw:/Jason P.*/

关于regex - Kibana : Cannot query with regex having space,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/35493703/

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