2015-08-25 279 views
1

我試圖在elasticsearch中構建一個嵌套聚合,但它不斷給出錯誤。它說「找不到agg類型標籤」。我該如何解決它。謝謝你的幫助.Btw我沒有嵌套文件我有一個文件有180個字段。我可以應用此聚合嗎?這裏是我的代碼:嵌套聚合Elasticsearch

{ 
    "aggs": { 
    "comments": { 
     "nested": { 
     "path": "comments" 
     }, 
    "aggs" : { 
    "red_products": { 
     "filter": { 
     "not": { 
      "terms": { 
      "text": [ 
       "06melihgokcek", 
       "t.co","??","????","???" 
      ] 
      } 
     } 
     }, 
     "aggs": { 
     "top_docs": { 
      "terms": { 
      "field": "text", 
      "size": 50 
      } 
     }, 

     "aggs" : { 
      "tags" : { 
      "terms" : { 
       "field" : "text", 
       "include" : ".*avni.*", 
       "exclude" : "fuat_.*" 
      } 
     } 
    } 
     } 


    } 
    } 
}}} 

回答

0

你的內心aggs(在底部的一個叫tags)是錯誤的,應該是top_docs一個子元素。

{ 
    "aggs": { 
    "comments": { 
     "nested": { 
     "path": "comments" 
     }, 
     "aggs": { 
     "red_products": { 
      "filter": { 
      "not": { 
       "terms": { 
       "text": [ 
        "06melihgokcek", 
        "t.co", 
        "??", 
        "????", 
        "???" 
       ] 
       } 
      } 
      }, 
      "aggs": { 
      "top_docs": { 
       "terms": { 
       "field": "text", 
       "size": 50 
       }, 
       "aggs": {     <---- this was the misplaced aggs 
       "tags": { 
        "terms": { 
        "field": "text", 
        "include": ".*avni.*", 
        "exclude": "fuat_.*" 
        } 
       } 
       } 
      } 
      } 
     } 
     } 
    } 
    } 
} 
+0

感謝您的幫助 –