2016-04-18 126 views
0

我有这个映射fuas类型:聚集在嵌套聚集场失败

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" } } 
     } 
    } 
    } 
} 
' 

ES实现我:

"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 
} 

任何想法?

回答

0

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

本来应该是:

"metainfos" : { 
    "type":"nested", 
    "properties" : { 
     "category 1" : { 
      "type" : "string" 
     }, 
     "key" : { 
      "type" : "string" 
     }, 
     "null" : { 
      "type" : "string" 
     }, 
     "processos" : { 
      "type" : "string" 
     } 
    } 
} 
+0

Thnaks!麻烦的是这个“映射”正在实时创建。所以,我正在序列化文档,ES创建映射。我不知道这是否是最好的选择。每个“元信息”是唯一的,只有一个值。 – Jordi

+0

然后你需要显式地为这个属性创建映射。请参阅https://www.elastic.co/guide/en/elasticsearch/reference/current/indices-put-mapping.html您需要在插入任何数据之前执行此操作! – mbudnik