不为失败找理由,要为成功找方法。

中文分词的特殊符号问题

Elasticsearch | 作者 beey | 发布于2018年05月03日 | 阅读数:4899

最近一个项目,已经安装了ik中文分词,并且设置了词典,但是词典中的词有中文括号,例如:
阿里巴巴国际旅行社(北京)有限公司
但是检索时,这个检索关键词就被分词了,怎么才能不被分词?
curl 'http://localhost:9200/xxxxxxxx/_analyze?analyzer=ik_smart&pretty=true' -d '{"text":"我们是阿里巴巴国际旅行社(北京)有限公司"}'
{
  "tokens" : [
    {
      "token" : "我们",
      "start_offset" : 0,
      "end_offset" : 2,
      "type" : "CN_WORD",
      "position" : 0
    },
    {
      "token" : "阿里巴巴",
      "start_offset" : 3,
      "end_offset" : 7,
      "type" : "CN_WORD",
      "position" : 1
    },
    {
      "token" : "国际",
      "start_offset" : 7,
      "end_offset" : 9,
      "type" : "CN_WORD",
      "position" : 2
    },
    {
      "token" : "旅行社",
      "start_offset" : 9,
      "end_offset" : 12,
      "type" : "CN_WORD",
      "position" : 3
    },
    {
      "token" : "北京",
      "start_offset" : 13,
      "end_offset" : 15,
      "type" : "CN_WORD",
      "position" : 4
    },
    {
      "token" : "有限公司",
      "start_offset" : 16,
      "end_offset" : 20,
      "type" : "CN_WORD",
      "position" : 5
    }
  ]
}
 
已邀请:

laoyang360 - 《一本书讲透Elasticsearch》作者,Elastic认证工程师 [死磕Elasitcsearch]知识星球地址:http://t.cn/RmwM3N9;微信公众号:铭毅天下; 博客:https://elastic.blog.csdn.net

赞同来自:

match_phrase短语匹配

要回复问题请先登录注册