Elasticsearch如何对高亮词进行精确显示 - Elastic 中文社区


本站和网页 https://elasticsearch.cn/question/509 的作者无关,不对其内容负责。快照谨为网络故障时之索引,不代表被搜索网站的即时页面。

Elasticsearch如何对高亮词进行精确显示 - Elastic 中文社区
你的浏览器禁用了JavaScript, 请开启后刷新浏览器获得更好的体验!
输入关键字进行搜索
搜索:
发起问题
发现
分享
文章
活动
下载
登录
亲,只收二进制
Elasticsearch如何对高亮词进行精确显示
Elasticsearch
| 作者 zhouliang
| 发布于2016年05月09日| 阅读数:16756
分享到:QQ空间新浪微博微信QQ好友印象笔记有道云笔记
我本地的es版本,是1.5.2,对数据建立索引时,并没有指定index_options的类型。(默认,应该是plain)
本地put条数据,大致的样子,是:
{"id": "20001",
"name": "江苏大学附属医院"}
查询语句:
curl localhost:9200/**-index/**/_search?pretty -d '{"query":{"bool":{"should":[{"match":{"name":{"query":"江苏人民医院","type":"boolean","boost":12.0}}}]}},"highlight":{"fields":{"name":{}}},"from":0,"size":2}'。
我的预期,对于hightlight部分,结果是:<em>江苏</em>省<em>人民医院</em>。
而实际结果是:<em>江苏省人员医院</em>,这个“省”字,也高亮了,与我预期不符。问题出在哪里?
Elasticsearch如何对高亮词进行精确显示
2016-05-09
添加评论
没有找到相关结果
已邀请:
与内容相关的链接
提交
3 个回复
qinpengfei
- 一个连电脑都玩不明白的逗逼
赞同来自:
1. highlight可以设置返回好几条的高亮字段,但是高亮的字段不可能和你预期的一模一样
2. highlight里面也可以写高亮的查询语句,看看能不能满足 highlight_query(https://www.elastic.co/guide/e ... g.html)
2016-05-12
分享
微博
flank
赞同来自:
检查下mapping,是否启用name这个字段的分词
2016-05-23
分享
微博
zhouliang
赞同来自:
该问题,通过一个简单的方式解决掉了:
在建立索引时,给name字段指定index_options类型,即:"index_options":"offsets"。
If index_options is set to offsets in the mapping the postings highlighter will be used instead of the plain highlighter. The postings highlighter:
Is faster since it doesn’t require to reanalyze the text to be highlighted: the larger the documents the better the performance gain should be
Requires less disk space than term_vectors, needed for the fast vector highlighter
Breaks the text into sentences and highlights them. Plays really well with natural languages, not as well with fields containing for instance html markup
Treats the document as the whole corpus, and scores individual sentences as if they were documents in this corpus, using the BM25 algorithm
2016-05-26
分享
微博
为什么被折叠?
0 个回复被折叠
要回复问题请先登录或注册
发起人
zhouliang
活动推荐 Mar18Elastic 中国开发者大会 2022深圳·3-18 周六·报名中 Apr292022年DAMS中国数据智能管理峰会-上海站上海·4-29 周六·报名中
相关问题
elasticsearch scroll查询的原理没太懂
我来写第一个帖子-你们都是什么时候知道elasticsearch的?
怎么解决elasticsearch集群占用太多虚拟内存(VIRT)的问题?占用了几十个G,有什么可以对它进行限制的相关设置吗?
ES集群如何进行挨个重启?
elasticsearch 设置 node.data: false 依然有数据
ES集群,进行大量删除操作时候,bulk队列溢出
ElasticSearch-Hadoop的目標是什麼呢??
elasticsearch functionScoreQuery scriptFunction效率问题
请教elasticsearch出现unassigned shards根本原因
如何清理Elasticsearch特定时间段数据?
Elasticsearch聚合操作的时间复杂度是O(n)吗?
问题状态
最新活动: 2016-05-26 10:08
浏览: 16756
关注: 7 人
Copyright © 2022 · CC BY-NC-SA 3.0
· Elastic中文社区
本站服务器及带宽由 提供赞助