进阶-第73__elasticsearch高手进阶_深入剖析搜索结果的highlight高亮显示

本文介绍了Elasticsearch中的高亮显示功能,包括一个基本的高亮例子,详细讲解了plain、posting和fast vector三种highlight方式,以及如何设置高亮HTML标签和片段设置。通过这些内容,读者可以了解如何优化搜索结果的展示,特别是在处理大量数据和提升性能方面。
摘要由CSDN通过智能技术生成

 

1、一个最基本的高亮例子

创建index的mappings

PUT /blog_website

{

  "mappings": {

    "blogs": {

      "properties": {

        "title": {

          "type": "text",

          "analyzer": "ik_max_word"

        },

        "content": {

          "type": "text",

          "analyzer": "ik_max_word"

        }

      }

    }

  }

}

 

看一下分词效果

GET /_analyze

{

  "text":"我发表的第一篇博课",

  "analyzer":"ik_max_word"

}

结果:

{

  "tokens": [

    {

      "token": "我",

      "start_offset": 0,

      "end_offset": 1,

      "type": "CN_CHAR",

      "position": 0

    },

    {

      "token": "发表",

      "start_offset": 1,

      "end_offset": 3,

      "type": "CN_WORD",

      "position": 1

    },

    {

      "token": "发",

      "start_offset": 1,

      "end_offset": 2,

      "type": "CN_WORD",

      "position": 2

    },

    {

      "token": "表",

      "start_offset": 2,

      "end_offset": 3,

      "type": "CN_WORD",

      "position": 3

    },

    {

      "token": "第一篇",

      "start_offset": 4,

      "end_offset": 7,

      "type": "CN_WORD",

      "position": 4

    },

    {

      "token": "第一",

      "start_offset": 4,

      "end_offset": 6,

      "type": "CN_WORD",

      "position": 5

    },

    {

      "token": "一篇",

      "start_offset": 5,

      "end_offset": 7,

      "type": "CN_WORD",

      "position": 6

    },

    {

      "token": "一",

      "start_offset": 5,

      "end_offset": 6,

      "type": "TYPE_CNUM",

      "position": 7

    },

    {

      "token": "篇",

      "start_offset": 6,

      "end_offset": 7,

      "type": "COUNT",

      "position": 8

    },

    {

      "token": "博",

      "start_offset": 7,

      "end_offset": 8,

      "type": "CN_CHAR",

      "position": 9

    },

    {

      "token": "课",

      "start_offset": 8,

      "end_offset": 9,

      "type": "CN_CHAR",

      "position": 10

    }

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值