、一个基本的高亮例子
PUT /blog_website
{
"settings": {
"number_of_shards": 1,
"number_of_replicas": 0
},
"mappings": {
"blogs": {
"properties": {
"title": {
"type": "text",
"analyzer": "ik_max_word"
},
"content": {
"type": "text",
"analyzer": "ik_max_word"
}
}
}
}
}
PUT /blog_website/blogs/1
{
"title":"我的第一篇博客",
"content":"大家好,这是我写的第一篇博客,特别喜欢这个博客网站"
}
GET /blog_website/blogs/_search
{
"query": {
"match": {
"title": "博客"
}
},
"highlight": {
"fields": {
"title": {}
}
}
}
{
"took": 85,
"timed_out": false,
"_shards": {
"total": 1,
"successful": 1,
"skipped": 0,
"failed": 0
},
"hits": {
"total": 1,
"max_score": 0.2876821,
"hits": [
{
"_index": "blog_website",
"_type": "blogs",
"_id": "1",
"_score": 0.2876821,
"_source": {
"title": "我的第一篇博客",
"content": "大家好,这是我写的第一篇博客,特别喜欢这个博客网站"
},
"highlight": {
"title": [
"我的第一篇<em>博客</