鍍金池/ 問答/Java  Python/ elasticsearch高亮不生效

elasticsearch高亮不生效

es5.5, 高亮沒有生效,例子是照搬官方文檔的,但返回結(jié)果沒有highlight字段,是不是某些設(shè)置問題? https://www.elastic.co/guide/...

GET /1266/default_type/_search
{
  "query" : {
    "match" : {
      "_all" : "who"
    }
  },
  "highlight": {
        "fields" : {
            "_all" : {}
        }
  }
}

返回

{
  "took": 50,
  "timed_out": false,
  "_shards": {
    "total": 5,
    "successful": 5,
    "failed": 0
  },
  "hits": {
    "total": 1000,
    "max_score": 0.002578699,
    "hits": [
      {
        "_index": "1266",
        "_type": "default_type",
        "_id": "8",
        "_score": 0.002578699,
        "_source": {
          "object_id": "8",
          "film_id": 8,
          "title": "AIRPORT POLLOCK",
          "description": "A Epic Tale of a Moose And a Girl who must Confront a Monkey in Ancient India",
          "release_year": 2006,
          "language_id": 1,
          "original_language_id": null,
          "rental_duration": 6,
          "rental_rate": "4.99",
          "length": 54,
          "replacement_cost": "15.99",
          "rating": "R",
          "special_features": "Trailers",
          "last_update": "2006-02-15 05:03:42"
        }
      },
回答
編輯回答
心夠野

你的高亮字段不可以設(shè)置為_all

In order to perform highlighting, the actual content of the field is required. If the field in question is stored (has store set to true in the mapping) it will be used, otherwise, the actual _source will be loaded and the relevant field will be extracted from it.
The _all field cannot be extracted from _source, so it can only be used for highlighting if it mapped to have store set to true.

關(guān)聯(lián)地址

意思是說,這個位置高亮查詢不可以對_all進行查詢,只允許對指定字段進行高亮。

2018年8月8日 20:41