Well,不要刷屏了

highlight 查询terms过多导致高亮无效

Elasticsearch | 作者 Jalor | 发布于2019年05月28日 | 阅读数:2862

我使用 es6.5 做查询,涉及到高亮查询,
(1).当使用match时,高亮能正常使用;
(2).使用terms查询时
    1.若词较少,高亮也正常;
{
  "query": {
    "constant_score": {
      "filter": {
        "terms": {
          "CONTENT": [
            "山东",
            "福建",
            "台湾",
            "河北",
            "河南",
            "重庆",
            "湖北",
            "湖南",
            "江西",
            "海南",
            "黑龙江",
            "天津",
            "贵州",
            "陕西",
            "新疆",
            "澳门"
          ]
        }
      }
    }
  },
  "highlight": {
    "fields": {
      "CONTENT": {}
    }
  }
}

    2.词过多,超过了17个,则高亮就无效
 
{
"query": {
"constant_score": {
"filter": {
"terms": {
"CONTENT": [
"山东",
"福建",
"台湾",
"河北",
"河南",
"重庆",
"湖北",
"湖南",
"江西",
"海南",
"黑龙江",
"天津",
"贵州",
"陕西",
"新疆",
"澳门",
"江苏",
"安徽",
"西藏",
"吉林",
"上海",
"山西",
"宁夏",
"香港",
"四川",
"广西",
"云南",
"甘肃省",
"内蒙古",
"浙江省",
"辽宁",
"广东",
"青海",
"北京"
]
}
}
}
},
"highlight": {
"fields": {
"CONTENT": {}
}
}
}

这是我的mapping
"CONTENT": {
"type": "text",
"term_vector": "with_positions_offsets",
"analyzer": "ik_smart",
"search_analyzer": "ik_max_word",
"fielddata": true
},
已邀请:

rochy - rochy_he

赞同来自:

高亮不支持 terms query,具体可以参考:
https://www.elastic.co/guide/e ... hting
 
Highlighters don’t reflect the boolean logic of a query when extracting terms to highlight. Thus, for some complex boolean queries (e.g nested boolean queries, queries using minimum_should_match etc.), parts of documents may be highlighted that don’t correspond to query matches.

要回复问题请先登录注册