elasticsearch之高亮查询
准备数据
PUT zhifou/doc/4 { "name":"石头", "age":29, "from":"gu", "desc":"粗中有细,狐假虎威", "tags":["粗", "大","猛"] }
默认高亮显示 highlight
GET zhifou/doc/_search { "query": { "match": { "name": "石头" } }, "highlight": { "fields": { "name": {} } } }
结果如下:
{ "took" : 1, "timed_out" : false, "_shards" : { "total" : 5, "successful" : 5, "skipped" : 0, "failed" : 0 }, "hits" : { "total" : 1, "max_score" : 1.5098256, "hits" : [ { "_index" : "zhifou", "_type" : "doc", "_id" : "4", "_score" : 1.5098256, "_source" : { "name" : "石头", "age" : 29, "from" : "gu", "desc" : "粗中有细,狐假虎威", "tags" : [ "粗", "大", "猛" ] }, "highlight" : { "name" : [ "<em>石</em><em>头</em>" #此处高亮显示 ] } } ] } }
自定义高亮显示
GET zhifou/chengyuan/_search { "query": { "match": { "from": "gu" } }, "highlight": { "pre_tags": "<b class=‘key‘ style=‘color:red‘>", "post_tags": "</b>", "fields": { "from": {} } } }
需要注意的是:自定义标签中属性或样式中的逗号一律用英文状态的单引号表示,应该与外部elasticsearch
语法的双引号区分开。
相关推荐
fenghuoliuxing0 2020-08-01
yhuihon 2020-05-31
苗疆三刀的随手记 2020-05-27
玫瑰小妖 2020-05-10
心丨悦 2020-05-08
zhanghaibing00 2020-04-21
Lius 2020-02-14
vshacker 2020-01-28
James0 2019-12-15
rootdream 2019-11-17
zycglboy 2019-11-12
Urchindong 2011-08-01
Mexican 2014-03-19
genglang 2018-08-17
89589432 2019-09-22
本文实例为大家分享了vue elementUI表格关键字筛选高亮的具体代码,供大家参考,具体内容如下。<el-input type="search" v-model="search" style="w
Johnjianyo 2019-05-28
技术相关 2019-04-23
Tomato 2018-10-17