2017-06-12 117 views
0

我有一个单一类型的索引,我想对它运行一些聚合查询;映射在这里:Elasticsearch对聚合查询返回空值

{ 
       "settings": { 
        "index": { 
         "number_of_shards": 1, 
         "number_of_replicas": 2 
        } 
       }, 
       "mappings": { 
        "v1": { 
         "_all": {"enabled": false}, 
         "properties": { 
          "@timestamp": { 
           "type": "date", 
           "format": "strict_date_optional_time||epoch_millis", 
           "index": true 

          }, 
          "processingTime":  {"type": "long", "index": false}, 
          "batchSize":   {"type": "long", "index": false}, 
          "general": { 
           "type": "nested", 
           "properties": { 
            "total":  {"type": "long"}, 
            "migrated":  {"type": "long"}, 
            "joined":  {"type": "long"}, 
            "registered": {"type": "long"} 
           } 
          }, 
          "scoped": { 
           "type": "nested", 
           "properties": { 
            "since":  {"type": "long"}, 
            "loggedIn":  {"type": "long"}, 
            "joined":  {"type": "long"}, 
            "registered": {"type": "long"} 
           } 
          } 
         } 
        } 
       } 
      } 

让我们看看我的查询;一个简单的日期直方图查询按分钟来收集基本数据:

{ 
    "size": 0, 
    "aggs": { 
     "x": { 
      "date_histogram":{ 
       "field": "@timestamp", 
       "interval": "minute" 
      }, 
      "aggs": { 
       "stat-x": { "stats": {"field": "general.registered"}} 
      } 
     } 
    } 
} 

但是当我运行我的查询(上面的),我得到空值的汇总统计数据,我不明白为什么!:

{ 
    "_shards": { 
     "failed": 0, 
     "successful": 1, 
     "total": 1 
    }, 
    "aggregations": { 
     "general": { 
      "doc_count": 2, 
      "max-x": { 
       "avg": null, 
       "count": 0, 
       "max": null, 
       "min": null, 
       "sum": null 
      } 
     } 
    }, 
    "hits": { 
     "hits": [], 
     "max_score": 0.0, 
     "total": 2 
    }, 
    "timed_out": false, 
    "took": 18 
} 

我不知道为什么它不工作!映射,类型和查询似乎是正确的!谁能帮我!

回答

0

问题是在定义一般作用域模式/映射;他们应该是Inner Objects但我已将它们定义为Netsted Object;然后弹性不能索引它们!