不要急,总有办法的

停止词无效

匿名 | 发布于2017年04月12日 | 阅读数:4023

PUT graph_v2
{
  "settings": {
    "analysis": {
      "analyzer": {
        "company_analyzer": {
          "type":"custom",
          "tokenizer":"ik_max_word",
          "stopwords": ["公司","有限","有限公司"]
        }
      }
    }
  },
  "mappings":{
    "person":{
       "properties":{
          "companyName": {
             "type":"string",
             "analyzer":"company_analyzer", 
             "search_analyzer":"company_analyzer"
            }
          }
       }
    }
}
查询
POST graph_v2/_analyze
{
  "analyzer": "company_analyzer",
  "text": "某某某管理有限公司"
}
 
结果

  "tokens": [
    {
      "token": "某某某",
      "start_offset": 0,
      "end_offset": 3,
      "type": "CN_WORD",
      "position": 0
    },
    {
      "token": "某某",
      "start_offset": 0,
      "end_offset": 2,
      "type": "CN_WORD",
      "position": 1
    },
    {
      "token": "某某",
      "start_offset": 1,
      "end_offset": 3,
      "type": "CN_WORD",
      "position": 2
    },
    {
      "token": "管理",
      "start_offset": 3,
      "end_offset": 5,
      "type": "CN_WORD",
      "position": 3
    },
    {
      "token": "有限公司",
      "start_offset": 5,
      "end_offset": 9,
      "type": "CN_WORD",
      "position": 4
    },
    {
      "token": "有限",
      "start_offset": 5,
      "end_offset": 7,
      "type": "CN_WORD",
      "position": 5
    },
    {
      "token": "公司",
      "start_offset": 7,
      "end_offset": 9,
      "type": "CN_WORD",
      "position": 6
    }
  ]
}
 
已邀请:

kennywu76 - Wood

赞同来自: hailang

ik的stop words不是怎么配置的,需要写到一个stop words的词典文件了,配置方法ik文档里有说。

要回复问题请先登录注册