嵌套聚合字段上的聚合失败

时间:2016-04-18 12:37:58

标签: elasticsearch

我有curl -XGET 'http://localhost:9201/living_team/_mapping/fuas?pretty' { "living_v1" : { "mappings" : { "fuas" : { "properties" : { "backlogStatus" : { "type" : "long" }, "comment" : { "type" : "string" }, "dueTimestamp" : { "type" : "date", "format" : "strict_date_optional_time||epoch_millis" }, "matter" : { "type" : "string" }, "metainfos" : { "properties" : { "category 1" : { "type" : "string" }, "key" : { "type" : "string" }, "null" : { "type" : "string" }, "processos" : { "type" : "string" } } }, "resources" : { "properties" : { "noteId" : { "type" : "string" }, "resourceId" : { "type" : "string" } } }, "status" : { "type" : "long" }, "timestamp" : { "type" : "date", "format" : "strict_date_optional_time||epoch_millis" }, "user" : { "type" : "string", "index" : "not_analyzed" } } } } } } 类型的这种映射:

curl -XGET 'http://ESNode01:9201/living_team/fuas/_search?pretty' -d '
{
  "aggs" : {
    "demo" : {
      "nested" : {
        "path" : "metainfos"
      },
      "aggs" : {
        "key" : { "terms" : { "field" : "metainfos.key" } }
      }
    }
  }
}
'

我正在尝试执行此聚合:

  "error" : {
    "root_cause" : [ {
      "type" : "aggregation_execution_exception",
      "reason" : "[nested] nested path [metainfos] is not nested"
    } ],
    "type" : "search_phase_execution_exception",
    "reason" : "all shards failed",
    "phase" : "query_fetch",
    "grouped" : true,
    "failed_shards" : [ {
      "shard" : 3,
      "index" : "living_v1",
      "node" : "HfaFBiZ0QceW1dpqAnv-SA",
      "reason" : {
        "type" : "aggregation_execution_exception",
        "reason" : "[nested] nested path [metainfos] is not nested"
      }
    } ]
  },
  "status" : 500
}
ES意识到我:

for /d %%a in (*) do dir /ad /on /s /b %%a

有什么想法吗?

1 个答案:

答案 0 :(得分:0)

您的metainfos映射中缺少"type":"nested"

应该是:

"metainfos" : {
    "type":"nested",
    "properties" : {
        "category 1" : {
            "type" : "string"
        },
        "key" : {
            "type" : "string"
        },
        "null" : {
            "type" : "string"
        },
        "processos" : {
            "type" : "string"
        }
    }
}
相关问题