简体   繁体   中英

Watson Discovery news aggregation returning null for filter and timeslice

I am using Java application to execute the aggregation and I am using dependency

<dependency>
 <groupId>com.ibm.watson.developer_cloud</groupId>
 <artifactId>java-sdk</artifactId>
 <version>3.8.0</version>
</dependency>

The aggregation is:

builder.filter("crawl_date>2017-08-11,crawl_date<2017-08-17");
builder.aggregation("filter(enriched_title.entities.type::Company).term(enriched_title.entities.text).timeslice(crawl_date,1day).term(enriched_text.sentiment.document.label)");
  QueryResponse response = discovery.query(builder.build()).execute();

but the response is coming as null. If the same code is placed in IBM Bluemix query builder it's giving proper output.

What could be causing this?

This issue may be occurring because you are missing the timezone parameter inside of your timeslice :

timeslice(crawl_date,1day,America/New York) //for example

Timeslice according IBM Watson Discovery Documentation is 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>) . To use timeslice, the time fields in your documents must be of the date data type and in ISO 8601 format. Unless both of these requirements are met, the timeslice parameter does not work correctly...

See the official reference using Aggregations here .

Actually, this is a limitation of the 3.8.0 version of the watson-developer-cloud/java-sdk - it currently does not support all the aggregation types that the API supports. Version 3.8.0 only supports "term", "histogram" and the calculations ("average", "min", "max", "sum").

You can see a list of all the outstanding issues related to the Watson Discovery Service at https://github.com/watson-developer-cloud/java-sdk/issues?q=is%3Aopen+is%3Aissue+label%3Adiscovery

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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