admin管理员组

文章数量:1530842

在elasticsearch中对数据进行聚合,想得出每个来源的数据量,mapping:

  "news_source": {
   
     "type": "text"
   },
   "related_freq": {
   
     "type": "integer"
   },

查询条件:

GET /event_news/_search
{
  "size": 0, 
  "aggs": {
    "news_source_info":{
      "terms": {
        "field": "news_source"
      },
      "aggs": {
        "total_sum": {
          "sum": {"field": "related_freq"}
        }
      }
    }
  }
}

结果报错

{
   
  "error": {
   
    "root_cause": [
      {
   
        "type": "illegal_argument_exception",
        "reason": "Fielddata is disabled on text fields by default. Set fielddata=true on [news_abstract] in order to load fielddata in memory by uninverting the inverted index. Note that this can however use significant memory. Alternatively use a keyword field instead."
      }
    ],
    "type": "search_phase_execution_exception",
    "reason": "all shards failed",
    "phase": "query",
    "grouped": true,
    "failed_shards": [
      {
   
        "shard": 0,
        "index": "event_news",
  

本文标签: 类型ElasticsearchText