8.2.1-elasticsearch内置分词器之standard/simple

ES默认提供了八种内置的analyzer,针对不同的场景可以使用不同的analyzer;

1、standard analyzer

1.1、standard类型及分词效果

在未显式指定analyzer的情况下standard analyzer为默认analyzer,其提供基于语法进行分词(基于Unicode文本分段算法)且在多数语言当中表现都不错;

//测试standard analyzer默认分词效果
//请求参数
POST _analyze
{
   
  "analyzer": "standard",
  "text": "transimission control protocol is a transport layer protocol"
}

//结果返回
{
   
  "tokens" : [
    {
   
      "token" : "transimission",
      "start_offset" : 0,
      "end_offset" : 13,
      "type" : "<ALPHANUM>",
      "position" : 0
    },
    {
   
      "token" : "control",
      "start_offset" : 14,
      "end_offset" : 21,
      "type" : "<ALPHANUM>",
      "position" : 1
    },
    {
   
      "token" : "protocol",
      "start_offset" : 22,
      "end_offset" : 30,
      "type" : "<ALPHANUM>",
      "position" : 2
    },
    {
   
      "token" : "is",
      "start_offset" : 31,
      "end_offset" : 33,
      "type" : "<ALPHANUM>",
      "position" : 3
    },
    {
   
      "token" : "a",
      "start_offset" : 34,
      "end_offset" : 35,
      "type" : "<ALPHANUM>",
      "position" : 4
    },
    {
   
      "token" : "transport",
      "start_offset" : 36,
      "end_offset" : 45,
      "type" : "<ALPHANUM>",
      "position" : 5
    },
    {
   
      "token" : "layer",
      "start_offset" : 46,
      "end_offset" : 51,
      "type" : "<ALPHANUM>",
      "position" : 6
    },
    {
   
      "token" : "protocol",
      "start_offset" : 52,
      "end_offset" : 60,
      "type" : "<ALPHANUM>",
      "position" : 7
    }
  ]
}

以上句子通过分词之后得到的关键词为:
[transmission, control, protocol, is, a, transport, layer, protocol]

1.2、standard类型可配置参数
序号 参数 参数说明
1 max_token_length 原始字符串拆分出的单个token所允许的最大长度,若拆分出的token查询超过最大值则按照最大值位置进行拆分,多余的作为另外的token,默认值为255;
2 stopwords 预定义的停用词,可以为0个或多个,例如_english_或数组类型值,默认值为_none_;
3 stopwords_path 停用词文件路径;

以下实例配置max_token_length参数

//standard参数配置定义
PUT standard_analyzer_token_length_conf_index
{
   
  "settings": {
   
    "analysis": {
   
      "analyzer": {
   
        "english_analyzer":{
   
          "type":"standard",
          "max_token_length":5,
          "stopwords":"_english_"
        }
      }
    }
  }
}

//测试standard可配置参数
  • 0
    点赞
  • 3
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值