Abt*_*Pst 9 regex elasticsearch kibana-4 elasticsearch-2.0
我有一个字段作为
author
Jason Pete
Jason Paul
Mike Yard
Jason Voorhies
Run Code Online (Sandbox Code Playgroud)
在 kibana 4.4 中我查询为
author:/Jason.*/
Run Code Online (Sandbox Code Playgroud)
所以我得到了所有记录
Jason Pete
Jason Paul
Jason Voorhies
Run Code Online (Sandbox Code Playgroud)
好吧,现在我想做
author:/Jason P.*/
Run Code Online (Sandbox Code Playgroud)
我预计
Jason Pete
Jason Paul
Run Code Online (Sandbox Code Playgroud)
但我明白了
No Records found :(
Run Code Online (Sandbox Code Playgroud)
我的正则表达式出了什么问题?Jason 之后还有其他方法指定空格字符吗?我什至尝试过
author:/Jason\sP.*/
Run Code Online (Sandbox Code Playgroud)
但仍然没有结果
这是因为您的author字段可能已被分析,因此该值Jason Pete被标记为两个标记jason和pete。因此,不可能查询这两个值。
如果您想改变这种行为,我建议您在字段外创建一个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"
}
}
}
}
}
}'
Run Code Online (Sandbox Code Playgroud)
更新映射后(确保将my_indexand替换my_type为您拥有的任何索引和映射类型名称),您需要重新索引数据,然后您将能够author.raw像这样查询 Kibana 中的字段:
author.raw:/Jason P.*/
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
13928 次 |
| 最近记录: |