Search code examples
node.jsibm-watsonconcept-insights

Watson Concept-Insights document list/limit option not working in nodeJS


I am building a new corpus using Watson Concept-Insights. I've created about 100 documents so far using nodeJS. If I use curl to list the documents, I can find all of them. However when I nodeJS to list the same set of documents, it consistently ignores the limit value and returns the default of 20 documents. Help!!

Essential code follows (account key replaced with 'myAccount'):

 var watson = require('watson-developer-cloud');
 var concept_insights = watson.concept_insights({ yada yada... this all works }

 params = { 'corpus': '/corpora/myAccount/theAdviser', 'limit': 200 };
 concept_insights.corpora.listDocuments(params, function(err,_res) {
    if (err) { console.log(err); }
    else { console.log(JSON.stringify(_res, null, 2)); 
    res.send(JSON.stringify(_res, null, 2)); }
  });

No matter what value is entered for the limit option, I always get 20 results. CURL, on the other hand, returns the full list or a subset based on the specified limit. The equivalent working curl statement is:

 curl -u "{userID}":"{password}" "https://gateway.watsonplatform.net/concept-insights-beta/api/v2/corpora/myAccount/theAdviser/documents?limit=200"

Solution

  • It looks like this was an oversight in the npm module. I just added support for the limit param, it should be released as v1.9.1 once the CI loop finishes.