行动是治愈恐惧的良药,而犹豫、拖延将不断滋养恐惧。

使用 highlight 的 boundary_chars参数后仍然从非边界字符截断

Elasticsearch | 作者 abelwu | 发布于2016年08月11日 | 阅读数:8858

测试数据如下:
PUT wpz_2

PUT wpz_2/_mapping/test
{
"properties": {
"test": {
"analyzer": "index_ansj",
"type": "string",
"term_vector": "with_positions_offsets"
}
}
}

PUT wpz_2/test/3
{
"test": ",全市工业80%以上的大型装备实现了信息化集成。投资2000万元启动“智慧企业”专项行动,重点支持工业企业无线、物联技术应用。"
}
GET wpz_2/test/_search
{
"query": {
"match": {
"test": "智慧"
}
}
, "highlight": {
"boundary_chars": ".,!?;,。?!",
"fragment_size": 30,
"fields": {
"test": {}
}
}
}
输出,注意其中强调部分:
{
"took": 4,
"timed_out": false,
"_shards": {
"total": 5,
"successful": 5,
"failed": 0
},
"hits": {
"total": 1,
"max_score": 0.057534903,
"hits": [
{
"_index": "wpz_2",
"_type": "test",
"_id": "3",
"_score": 0.057534903,
"_source": {
"test": ",全市工业80%以上的大型装备实现了信息化集成。投资2000万元启动“智慧企业”专项行动,重点支持工业企业无线、物联技术应用。"
},
"highlight": {
"test": [
"[i][b]集成。[/b][/i]投资2000万元启动“<em>智慧</em>企业”专项行动,重点支持工业企业无线、物联技术应用"
]
}
}
]
}
}

analyzer用standard结果是一样的,所以不应该是分析器的问题。
我猜是boundary_chars和fragment_size两个参数共同起作用的机制有问题,不知道有没有办法保证开始出一定是从boundary char截断的?

 
已邀请:

viawang

赞同来自:

highlight 加参数 "type":"fvh", 可以解决Boundary 问题

要回复问题请先登录注册