博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
ElasticSearch(二十六)修改分词器及定制自己的分词器
阅读量:4353 次
发布时间:2019-06-07

本文共 1366 字,大约阅读时间需要 4 分钟。

1、默认的分词器

standard 分词器

standard tokenizer:以单词边界进行切分

standard token filter:什么都不做
lowercase token filter:将所有字母转换为小写
stop token filer(默认被禁用):移除停用词,比如a the it等等

2、修改分词器的设置

启用english停用词token filter

PUT /my_index{  "settings": {    "analysis": {      "analyzer": {        "es_std": {          "type": "standard",          "stopwords": "_english_"        }      }    }  }}GET /my_index/_analyze{  "analyzer": "standard",   "text": "a dog is in the house"}GET /my_index/_analyze{  "analyzer": "es_std",  "text":"a dog is in the house"}

3、定制化自己的分词器

1.&字符转换

2.停用某些词

3.大小写转换

PUT /my_index{  "settings": {    "analysis": {      "char_filter": {        "&_to_and": {          "type": "mapping",          "mappings": ["&=> and"]        }      },      "filter": {        "my_stopwords": {          "type": "stop",          "stopwords": ["the", "a"]        }      },      "analyzer": {        "my_analyzer": {          "type": "custom",          "char_filter": ["html_strip", "&_to_and"],          "tokenizer": "standard",          "filter": ["lowercase", "my_stopwords"]        }      }    }  }}GET /my_index/_analyze{  "text": "tom&jerry are a friend in the house, , HAHA!!",  "analyzer": "my_analyzer"}PUT /my_index/_mapping/my_type{  "properties": {    "content": {      "type": "text",      "analyzer": "my_analyzer"    }  }}

 

转载于:https://www.cnblogs.com/ql211lin/p/10909375.html

你可能感兴趣的文章
java8的十大新特性
查看>>
Ms sql server 数据类型说明
查看>>
shadow密码文件
查看>>
归并排序及优化(Java实现)
查看>>
kubernates使用kubeadm安装
查看>>
图说超线程技术(Hyper-Threading Technology)
查看>>
首页跳转
查看>>
insert into select 与select into from -- sql 批量插入
查看>>
剑指offer-二叉树的镜像
查看>>
关于 Activity 中 startActivityForResult 和 onActivityResult
查看>>
Entity Framework Code First (一)Conventions
查看>>
asp.net程序集强签名
查看>>
numpy数据集
查看>>
为什么Python是最适合初创公司的编程语言?
查看>>
Python中scatter函数参数用法详解
查看>>
iOS开发之支付宝一篇通
查看>>
快速排序,归并排序
查看>>
Windows下Subversion的安装及配置
查看>>
【cs229-Lecture4】GLMS:选定指数分布族,如何用它来推导出GLM?
查看>>
从Scratch到Python——python turtle 一种比pygame更加简洁的实现
查看>>