Elasticsearch奇怪的术语汇总(Elasticsearch strange terms a

2019-10-22 17:55发布

有聚集奇怪的术语,如果另一个映射包含不同类型的同一属性的名称:

MAPPING

{
  "mappings" : {
    "access" : {
      "properties" : {
        "cache" : { "type" : "string" }  
      }
    },
    "foo" : {
      "properties" : {
        "foobar" : { "type" : "float" },
        "cache"  : { "type" : "integer" }
      }
    }
  }
}

批量数据

{"create":{"_type":"foo"}}
{"foobar":[63.8828,66.3633,221.09,736.824,11.4336],"cache":[0,1536000]}

QUERY

curl -XGET "http://localhost:9200/test/access/_search?pretty=1" -d '{
    query : { match_all : {} },
    aggs : {
        testagg : {
            terms : { 
                field           : "cache", 
                min_doc_count   : 0
            }
        }
    }
}'

结果

{
  "took" : 1,
  "timed_out" : false,
  "_shards" : {
    "total" : 5,
    "successful" : 5,
    "failed" : 0
  },
  "hits" : {
    "total" : 0,
    "max_score" : null,
    "hits" : [ ]
  },
  "aggregations" : {
    "testagg" : {
      "doc_count_error_upper_bound" : 0,
      "sum_other_doc_count" : 0,
      "buckets" : [ {
        "key" : "`\b\u0000\u0000\u0000\u0000",
        "doc_count" : 0
      }, {
        "key" : "`\b\u0000]`\u0000",
        "doc_count" : 0
      }, {
        "key" : "h\u0004\u0000\u0000\u0000",
        "doc_count" : 0
      }, {
        "key" : "h\u0004\u0000.p",
        "doc_count" : 0
      }, {
        "key" : "p\u0002\u0000\u0000",
        "doc_count" : 0
      }, {
        "key" : "p\u0002\u0000\u0017",
        "doc_count" : 0
      }, {
        "key" : "x\u0001\u0000",
        "doc_count" : 0
      } ]
    }
  }
}

NO AGG QUERY

curl -XGET 'http://localhost:9200/test/_search?pretty=1'
{
  "took" : 2,
  "timed_out" : false,
  "_shards" : {
    "total" : 5,
    "successful" : 5,
    "failed" : 0
  },
  "hits" : {
    "total" : 1,
    "max_score" : 1.0,
    "hits" : [ {
      "_index" : "test",
      "_type" : "foo",
      "_id" : "AUzS6wyGwkgefuU3DR2R",
      "_score" : 1.0,
      "_source":{"foobar":[63.8828,66.3633,221.09,736.824,11.4336],"cache":[0,1536000]}
    } ]
  }
}

我不知道为什么,当我聚集了空访问映射我得到这些奇怪的术语......是不是有什么毛病我的结构或可能是一个错误的Elasticsearch?

Answer 1:

我通过谷歌搜索找到你的问题 - 你和我正在运行到同样的问题。

不幸的是,我们俩都从这个bug痛苦: https://github.com/elastic/elasticsearch/issues/8614 -在不同的映射相同的字段名需要共享相同的类型。



文章来源: Elasticsearch strange terms aggregation