使用Node.js发送AlchemyData新闻查询(watson-developer-cloud模块)

我目前正在使用watson-developer-cloud Node.js SDK来处理Node.js,并且在发送包含实体的查询时遇到问题。

这是我的代码:

// require watson's node sdk and fs var watson = require('watson-developer-cloud'); var fs = require('fs'); // Define output file var outputJSONFile = '/home/vagrant/Desktop/node/dir/data.json'; // Create alchemy_data_news object using our api_key var alchemy_data_news = watson.alchemy_data_news({ api_key: '' }); // Define params for the query and what values to return // Accepted returne values: // docs.alchemyapi.com/v1.0/docs/full-list-of-supported-news-api-fields var params = { start: 'now-1m', end: 'now', count: 2, qs: ['q.enriched.url.enrichedTitle.entities.entity.text=apple'], return: ['enriched.url.url,enriched.url.title'] }; // Call getNews method and return json alchemy_data_news.getNews(params, function (err, news) { if (err) { console.log('error:', err); } else { fs.writeFile(outputJSONFile, JSON.stringify(news, null, 2), function(err) { if (err) { console.log('WriteFile Error:', err); } else { console.log("JSON saved to " + outputJSONFile); } }); } }); 

我仍然试图找出如何使用params对象发送实体参数。

通过一些代码挖掘我碰到了QS,所以我一直在使用它来testing,但我没有成功。

任何build议,非常感谢。

PS:我试图通过:
q.enriched.url.enrichedTitle.entities.entity.text = apple q.enriched.url.enrichedTitle.entities.entity.type = company

如果您查看AlchemyDataNews的node-sdk源代码 ,您将看到顶级参数正在作为查询string发送。
那么params地图应该是:

 var params = { start: 'now-1m', end: 'now', count: 2, return: ['enriched.url.url,enriched.url.title'], // fields here 'q.enriched.url.enrichedTitle.entities.entity.text': 'apple', 'q.enriched.url.enrichedTitle.entities.entity.type': 'company' };