![](/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.