![](/img/trans.png)
[英]Watson Discovery news aggregation returning null for filter and timeslice
[英]Watson Discovery news aggregation by timeslice returns null
我在Java應用程序中對IBM Watson Discovery Service API運行查詢:
queryBuilder.filter("blekko.hostrank>20,blekko.chrondate>1492552800,blekko.chrondate<1493157600,blekko.documentType:!\"blog\",blekko.documentType:!\"review\",language:english");
queryBuilder.query("text:" + brand);
queryBuilder.aggregation("[timeslice(blekko.chrondate,1day), term(docSentiment.type)]");
QueryResponse queryResponse = discovery.query(queryBuilder.build()).execute();
對於聚合,我有以下輸出:
"aggregations": [
null,
{
"results": [
{
"key": "positive",
"matching_results": 245
},
{
"key": "negative",
"matching_results": 219
},
{
"key": "neutral",
"matching_results": 11
}
],
"type": "term",
"field": "docSentiment.type"
}
]
時間片聚合返回null。 有人對此有經驗嗎? 謝謝。
查看文檔,可能會出現此問題,因為您缺少時間片內部的timezone參數:
時間片:一種特殊的直方圖,使用日期創建間隔段。 有效的日期間隔值為分鍾,小時,天,周,月和年。 語法為
timeslice(<field>,<interval>,<time_zone>)
。 要使用時間片,文檔中的時間字段必須為日期數據類型,且格式為ISO 8601。 除非同時滿足這兩個要求,否則timeslice參數將無法正常工作...
有關時間片和其他聚合的更多信息,請參見“ 查詢構建參考” 。
我還建議您使用Watson Discovery API Explorer,以便更輕松地測試查詢並查看輸出:
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.