按数字搜索时弹性搜索未给出结果

时间:2019-01-22 07:01:54

标签: elasticsearch

我是ElasticSearch的新手。使用时遇到问题。有一个文本字段body,其中包含类似于XYZ1234的字符串,这是我们文档中的一种模式。但是,当我通过数字1234搜索它时,无法获得预期的结果。 在互联网上搜索后,我知道它与Analyzer有关。但是我不知道该如何处理。

PUT /customer

PUT /customer/_doc/1?pretty
{
  "body": "XYZ1234 blabla bla"
}

GET /customer/_search
{
  "query": {
    "match": {
      "body": "1234"
    }
  }
}

我也在下面尝试过

POST _analyze
{
  "analyzer": "standard",
  "text": "XYZ1234"
}

我知道了

{
  "tokens" : [
    {
      "token" : "xyz1234",
      "start_offset" : 0,
      "end_offset" : 7,
      "type" : "<ALPHANUM>",
      "position" : 0
    }
  ]
}

似乎令牌未拆分。如何获得结果,如果我搜索1234,那么我可以使用XYZ1234

获得内容

0 个答案:

没有答案
相关问题