是时候用 ES 拯救发际线啦

elasticsearch 2.3的 highlight有bug呀

Elasticsearch | 作者 MCTW | 发布于2018年09月21日 | 阅读数:2334

系统提示:这个人太懒了,什么问题描述都没有写!

已邀请:

MCTW - 90后IT男

赞同来自:

POST test_index/test/1
{
"product": "一吃饭",
"company": "腾讯"
}

POST test_index/test/2
{
"product": "一睡觉",
"company": "腾讯"
}

GET test_index/test/_search
{
"query": {
"bool": {
"should": [
{"match": {"company": "腾讯"}},
{"match_phrase": {"product": "一二三"}}
]
}
},
"highlight": {
"fields": {
"company": {},
"product": {}
}
}
}

得到的结果里边还会高亮 product??,在es2.4里测试就没有这个问题
{
  "took": 2,
  "timed_out": false,
  "_shards": {
    "total": 5,
    "successful": 5,
    "failed": 0
  },
  "hits": {
    "total": 2,
    "max_score": 0.025070842,
    "hits": [
      {
        "_index": "test_index",
        "_type": "test",
        "_id": "2",
        "_score": 0.025070842,
        "_source": {
          "product": "一睡觉",
          "company": "腾讯"
        },
        "highlight": {
          "product": [
            "<em>一</em>睡觉"
          ],
          "company": [
            "<em>腾</em><em>讯</em>"
          ]
        }
      },
      {
        "_index": "test_index",
        "_type": "test",
        "_id": "1",
        "_score": 0.025070842,
        "_source": {
          "product": "一吃饭",
          "company": "腾讯"
        },
        "highlight": {
          "product": [
            "<em>一</em>吃饭"
          ],
          "company": [
            "<em>腾</em><em>讯</em>"
          ]
        }
      }
    ]
  }
}

要回复问题请先登录注册