0

如题

我是 elasticsearch-7.4.2 的新手。我想使用搜索 API 来获取一些带有空格的令牌。

就像是

curl -X POST "localhost:9200/_analyze?pretty" -H 'Content-Type: application/json' -d'
{
    "analyzer" : "standard",
    "text": "agnes b"
}
'

返回

{
  "tokens" : [
    {
      "token" : "agnes",
      "start_offset" : 0,
      "end_offset" : 5,
      "type" : "<ALPHANUM>",
      "position" : 0
    },
    {
      "token" : "b",
      "start_offset" : 6,
      "end_offset" : 7,
      "type" : "<ALPHANUM>",
      "position" : 1
    }
  ]
}

我想获得令牌“agnes b”我该如何解决这个问题。

4

1 回答 1

1

您需要使用keyword分析器而不是分析器standard

curl -X POST "localhost:9200/_analyze?pretty" -H 'Content-Type: application/json' -d'
{
    "analyzer" : "keyword",           <-- change this
    "text": "agnes b"
}
'
于 2019-12-06T09:15:47.163 回答