我有点怀疑你在刷屏

搜索结果未能高亮搜索词 (BM25)

Elasticsearch | 作者 ESimon | 发布于2019年12月19日 | 阅读数:1394

ElasticSearch Version: 6.5.4
运行环境:MacOS Mojave

场景:我在使用内容 吉林期中试题  进行搜索时同批次结果中有的结果对 包含 吉林、期中、试题 的标题进行了高亮 有的却没有全部高亮 因为考虑词频问题 title 在创建索引时 similarity 指定使用了 BM25 ,在未指定使用BM25的默认情况下 未出现该问题

结果如下所示

11.png


22.png

 
请求的DSL:
{
"_source": [
"id",
"stage",
"subject_id",
"title"
],
"size": 20,
"query": {
"function_score": {
"query": {
"bool": {
"must": [
{
"multi_match": {
"query": "吉林期中试题",
"fields": [
"title^3"
],
"tie_breaker": 0.3,
"type": "best_fields",
"minimum_should_match": "90%"
}
},
{
"terms": {
"flag": [
7,
8,
17,
19
]
}
}
]
}
},
"boost_mode": "multiply",
"functions": [
{
"exp": {
"created_at": {
"origin": "now",
"scale": "3650d",
"decay": 0.3
}
}
}
]
}
},
"highlight": {
"pre_tags": "<em>",
"post_tags": "</em>",
"encoder": "html",
"fields": {
"title": {
"fragment_size": 500,
"number_of_fragments": 1
},
"intro": {
"fragment_size": 500,
"number_of_fragments": 1
}
}
}
}

 
已邀请:

ESimon - 90后IT男

赞同来自:

来个人安慰下也好呀,太冷清了

medcl - 今晚打老虎。

赞同来自:

索引的 Mapping 也发一下看看。

dongkaihuahit - 活到老,编到老

赞同来自:

要回复问题请先登录注册