您当前的位置: 首页 > 慢生活 > 程序人生 网站首页程序人生
elasticSearch分析
发布时间:2021-09-04 12:43:41编辑:雪饮阅读()
ElasticSearch分析api主要用于拆词,就是将一段文本按单词拆分,然后每天单词都返回其在整个文本中的索引(下标/偏移),包含开始偏移与结束偏移。
请求正文:
{
"analyzer" : "standard",
"text" : "you are reading this at YIIBAI point"
}
响应正文:
{
"tokens": [
{
"token": "you",
"start_offset": 0,
"end_offset": 3,
"type": "<ALPHANUM>",
"position": 0
},
{
"token": "are",
"start_offset": 4,
"end_offset": 7,
"type": "<ALPHANUM>",
"position": 1
},
{
"token": "reading",
"start_offset": 8,
"end_offset": 15,
"type": "<ALPHANUM>",
"position": 2
},
{
"token": "this",
"start_offset": 16,
"end_offset": 20,
"type": "<ALPHANUM>",
"position": 3
},
{
"token": "at",
"start_offset": 21,
"end_offset": 23,
"type": "<ALPHANUM>",
"position": 4
},
{
"token": "yiibai",
"start_offset": 24,
"end_offset": 30,
"type": "<ALPHANUM>",
"position": 5
},
{
"token": "point",
"start_offset": 31,
"end_offset": 36,
"type": "<ALPHANUM>",
"position": 6
}
]
}
可以看到这里给定的文本是"you are reading this at YIIBAI point",这里以token来标记每个拆出来的单词,一个token就记录一个单词。响应结果中每个拆出来的词的对象中都包含开始偏移和接受偏移。
这种功能就暂时我是没有发现应该用于什么场合。
关键字词:elasticSearch,分析