在Elasticsearch 1.6中运行Stats-Aggregation时获取异常

时间:2016-01-15 10:27:59

标签: elasticsearch

我有2种索引类型a)Custom_Pattern_1,b)Custom_DataType_2 inside' bw-2016-01-15-06-006'指数。 对于这两种索引类型,我有两个相同名称但数据类型不同的字段

  
      
  1. Custom_Pattern_1- Custom_DataType - String
  2.   
  3. Custom_DataType_2 - Custom_DataType - Long
  4.   

我正在查询聚合以下。

POST bw-2016-01-15-06-006/Custom_DataType_2/_search
{
  "from" : 0,
  "size" : 100,
  "aggregations" : {
        "Custom_DataType" : {
          "extended_stats" : {
            "field" : "Custom_DataType"
          }
        }
      }
}

虽然我只在Custom_DataType2里面运行查询' bw-2016-01-15-06-006' Custom_DataType很长的索引,应该返回结果。但我得到的是ClassCastException。

{
   "error": "SearchPhaseExecutionException[Failed to execute phase [query], all shards failed; shardFailures {[-lo5bj-4TLOcyZwfl6oPyA][bw-2016-01-15-06-006][0]: ClassCastException[org.elasticsearch.index.fielddata.plain.PagedBytesIndexFieldData cannot be cast to org.elasticsearch.index.fielddata.IndexNumericFieldData]}{[-lo5bj-4TLOcyZwfl6oPyA][bw-2016-01-15-06-006][1]: ClassCastException[org.elasticsearch.index.fielddata.plain.PagedBytesIndexFieldData cannot be cast to org.elasticsearch.index.fielddata.IndexNumericFieldData]}{[-lo5bj-4TLOcyZwfl6oPyA][bw-2016-01-15-06-006][2]: ClassCastException[org.elasticsearch.index.fielddata.plain.PagedBytesIndexFieldData cannot be cast to org.elasticsearch.index.fielddata.IndexNumericFieldData]}{[-lo5bj-4TLOcyZwfl6oPyA][bw-2016-01-15-06-006][3]: ClassCastException[org.elasticsearch.index.fielddata.plain.PagedBytesIndexFieldData cannot be cast to org.elasticsearch.index.fielddata.IndexNumericFieldData]}]",
   "status": 500
}

我仍在使用 Elasticsearch 1.6 ,根据文档,一个索引可以有两个同名且具有不同数据类型的字段。 有人可以帮我这个

1 个答案:

答案 0 :(得分:0)

需要一些挖掘,但我终于找到了我正在寻找的article。我记得前一段时间读过这篇文章。由于Lucene存储文档的方式,您不能在不同的索引中使用不同的数据类型命名完全相同的字段。这实际上是0.9.2中的一个问题,但我完全可以想象它已经通过1.x版本的方式,可能值得一试。