elasticsearch强调不起作用

时间:2018-02-20 02:40:41

标签: elasticsearch

Elasticsearch 5.5 使用文档中的示例,无法从结果中获取高亮字段。 该文件说store是必需的。但是'标题'字段已经存储。

映射

PUT my_index
{
  "mappings": {
    "user": {
      "properties": {
        "title": {
          "type": "text",
          "store": true 
        },
        "date": {
          "type": "date",
          "store": true 
        },
        "content": {
          "type": "text"
        }
      }
    }
  }
}

索引

PUT my_index/user/1
{
  "title":   "Some short title",
  "date":    "2015-01-01",
  "content": "A very long content field..."
}

查询

GET my_index/_search
{
  "query" : {
    "match" : {
      "_all" : "short"
    }
  },
  "highlight": {
        "fields" : {
            "_all" : {}
        }
  }
}

输出

{
  "took": 11,
  "timed_out": false,
  "_shards": {
    "total": 5,
    "successful": 5,
    "failed": 0
  },
  "hits": {
    "total": 1,
    "max_score": 0.24257512,
    "hits": [
      {
        "_index": "my_index",
        "_type": "user",
        "_id": "1",
        "_score": 0.24257512,
        "_source": {
          "title": "Some short title",
          "date": "2015-01-01",
          "content": "A very long content field..."
        }
      }
    ]
  }
}

输出json中没有高亮字段。 一定有什么不对劲。请提前指出,请指出。

0 个答案:

没有答案