6

我有一个领域

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.*/

但仍然没有结果

4

2 回答 2

2

这是因为您的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),您需要重新索引您的数据,然后您将能够author.raw像这样在 Kibana 中查询该字段:

author.raw:/Jason P.*/
于 2016-02-19T04:21:29.670 回答
0

它对我有用:

    author:/Jason\ P.*/

所以反斜杠\s空间在我的情况下适用于空间,ES1.7并且Kibana4.1.2.

于 2016-03-04T09:54:53.147 回答