简体   繁体   English

Watson Discovery按时间片的新闻聚合返回null

[英]Watson Discovery news aggregation by timeslice returns null

I run a query to IBM Watson Discovery service API in a java application: 我在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();

I have the following output in the response for the aggregation: 对于聚合,我有以下输出:

"aggregations": [
    null,
    {
      "results": [
        {
          "key": "positive",
          "matching_results": 245
        },
        {
          "key": "negative",
          "matching_results": 219
        },
        {
          "key": "neutral",
          "matching_results": 11
        }
      ],
      "type": "term",
      "field": "docSentiment.type"
    }
  ]

The timeslice aggregations returns null. 时间片聚合返回null。 Has anybody got experience on that? 有人对此有经验吗? Thank you. 谢谢。

Looking at the documentation, this issue may be occurring because you are missing the timezone parameter inside of your timeslice: 查看文档,可能会出现此问题,因为您缺少时间片内部的timezone参数:

timeslice: A specialized histogram that uses dates to create interval segments. 时间片:一种特殊的直方图,使用日期创建间隔段。 Valid date interval values are minute, hour, day, week, month, and year. 有效的日期间隔值为分钟,小时,天,周,月和年。 The syntax is timeslice(<field>,<interval>,<time_zone>) . 语法为timeslice(<field>,<interval>,<time_zone>) To use timeslice, the time fields in your documents must be of the date data type and in ISO 8601 format. 要使用时间片,文档中的时间字段必须为日期数据类型,且格式为ISO 8601。 Unless both of these requirements are met, the timeslice parameter does not work correctly... 除非同时满足这两个要求,否则timeslice参数将无法正常工作...

More information about timeslice and other aggregations can be found in the Query building reference . 有关时间片和其他聚合的更多信息,请参见“ 查询构建参考”

I would also recommend using the Watson Discovery API Explorer to make it easier to test your query and see the output: 我还建议您使用Watson Discovery API Explorer,以便更轻松地测试查询并查看输出:

Watson Discovery API Reference Watson Discovery API参考

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM