分词器
把一段话进行切割分成词组的方式
设置模板
指定字段的默认分词器,利用kibana的DEV Tools调试
GET /crm-cache-master-2019.09.23/_search
GET /crm-cache-master-2019.09.23/_mapping
# 搜索jobhandler查询不到结果
POST _analyze
{
"analyzer": "whitespace",
"text": "com.zhenai.crm.job.executor.service.jobhandler.wechat.ResourceRegisterJob"
}
# 搜索jobhandler查询不到结果
POST _analyze
{
"analyzer": "standard",
"text": "com.zhenai.crm.job.executor.service.jobhandler.wechat.ResourceRegisterJob"
}
# 搜索jobhandler查询不到结果
POST _analyze
{
"analyzer": "keyword",
"text": "com.zhenai.crm.job.executor.service.jobhandler.wechat.ResourceRegisterJob"
}
# 按照单词分词, 搜索jobhandler能查到
POST _analyze
{
"analyzer": "pattern",
"text": "com.zhenai.crm.job.executor.service.jobhandler.wechat.ResourceRegisterJob"
}
# 支持中文分词,搜索jobhandler能查到
POST _analyze
{
"analyzer": "ik_max_word",
"text": "com.zhenai.crm.job.executor.service.jobhandler.wechat.ResourceRegister: 活动报名列表查询:ApplyListQuery"
}
# 指定索引字段使用的分词器
PUT twitter
{
"mappings": {
"_doc": {
"properties": {
"message": {
"type": "text",
"analyzer": "pattern"
}
}
}
}
}
PUT twitter/_doc/2
{
"user":"test",
"@timestamp":"2019-09-25T01:09:21.969Z",
"message": "com.zhenai.crm.job.executor.service.jobhandler.wechat.ResourceRegisterJob"
}
DELETE /twitter
# 通过模板设置索引默认分词器和特定字段分词
GET /_template/template_server_log
DELETE /_template/template_server_log
PUT /_template/template_server_log
{
"index_patterns": ["datalogs*"],
"settings": {
"index.analysis.analyzer.default.type": "ik_max_word"
}
},
"mappings": {
"doc": {
"properties": {
"message": {
"type": "text",
"analyzer": "pattern"
}
}
}
}
}
# 查看es集群所有设置
GET /_cluster/settings?include_defaults=true
网友评论