您当前的位置: 首页 > 慢生活 > 程序人生 网站首页程序人生
elasticSearch创建指定字段分析器
发布时间:2021-09-10 15:09:39编辑:雪饮阅读()
上一篇了解了一个比较复杂的elasticSearch分析器的深度定制。
那么本篇中来了解一个简单的分析器创建于索引中。
这里要实现的目标是为一个索引中一个字段指定使用一个内置分析器,例如使用whitespace分析器。
那么一个创建指定字段分析器的实例如:
请求正文:
{
"mappings": {
"properties": {
"title": {
"type": "text",
"analyzer": "whitespace"
}
}
}
}
响应正文:
{
"acknowledged": true,
"shards_acknowledged": true,
"index": "my-index-000001"
}
这里将title给设置了whitespace内置分析器(空白分析器)
该whitespace分析仪将文本分为方面每当遇到任何空白字符。它不使用小写术语。
那么接下来就是使用这个指定字段分析器的索引中的这个指定字段title去分析一个文本来试试效果了
请求正文:
{
"field": "title",
"text": "The old brown cow"
}
响应正文:
{
"tokens": [
{
"token": "The",
"start_offset": 0,
"end_offset": 3,
"type": "word",
"position": 0
},
{
"token": "old",
"start_offset": 4,
"end_offset": 7,
"type": "word",
"position": 1
},
{
"token": "brown",
"start_offset": 8,
"end_offset": 13,
"type": "word",
"position": 2
},
{
"token": "cow",
"start_offset": 14,
"end_offset": 17,
"type": "word",
"position": 3
}
]
}
关键字词:elasticSearch,创建指定字段分析器,指定字段,分析器
相关文章
- elasticSearch创建custom分析器char_filter,tokenizer
- elasticSearch创建custom分析器搭载html条带字符过滤
- elasticSearch内置分析器(停用词的使用)
- elasticSearch索引中创建自定义分析器(custom)及按分
- elasticSearch测试分析仪-标准标记器与ASCII码折叠标
- elasticSearch测试分析仪
- elasticSearch类型的自动创建、动态映射与cluster.rou
- elasticSearch集群重新路由
- elasticSearch禁用自动分片分配(cluster.routing.allo
- elasticSearch将未分配的分片分配给节点