Skip to content

Commit 3c19f3e

Browse files
committed
bug fixed with create ranker
1 parent 3209d36 commit 3c19f3e

2 files changed

Lines changed: 27 additions & 38 deletions

File tree

services/retrieve_and_rank/v1.html

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -398,7 +398,15 @@
398398
</script>
399399

400400
<script type="text/x-red" data-help-name="watson-retrieve-rank-cluster-settings">
401-
401+
<p>The IBM Watson™ Retrieve and Rank service combines two information retrieval components in a single service: the power of Apache Solr and a sophisticated machine learning capability. This combination provides users with more relevant results by automatically reranking them by using these machine learning algorithms.</p>
402+
<p>The cluster settings node provides the following functionality configurable in the node configuration panel:</p>
403+
<ul>
404+
<li><b>List Clusters </b>Returns a list of all clusters in the service. Note there is a maximum of <b>5</b> clusters.</li>
405+
<li><b>Cluster Information </b>Returns status and other information about a cluster. The <code>cluster_id</code> is specified in the node configuration panel.</li>
406+
<li><b>Delete Cluster </b>Delete a cluster from the service. The <code>cluster_id</code> is specified in the node configuration panel.</li>
407+
</ul>
408+
<p>The response from each query is returned on <code>msg.payload</code>.</p>
409+
<p>For more information about the Retrieve and Rank service, read the <a href="https://www.ibm.com/smarterplanet/us/en/ibmwatson/developercloud/retrieve-rank.html">documentation</a>.</p>
402410
</script>
403411

404412
<script type="text/javascript">

services/retrieve_and_rank/v1.js

Lines changed: 18 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -43,47 +43,27 @@ module.exports = function (RED) {
4343

4444
this.on('input', function(msg) {
4545
setupRankRetrieveNode(msg,config,this,function(retrieve_and_rank) {
46-
47-
if (!msg.payload instanceof Buffer) {
48-
var message = 'Invalid property: msg.payload, must be a Buffer.';
46+
if (!msg.payload instanceof String) {
47+
var message = 'Invalid property: msg.payload, must be a String.';
4948
node.error(message, msg);
5049
return;
5150
}
52-
53-
var createRanker = function(training_data, cb) {
54-
var params = {
55-
training_data: training_data
56-
};
57-
console.log(training_data);
58-
59-
if (config.rankername) {
60-
params.training_metadata = "{\"name\": \""+config.rankername+"\"}";
61-
}
62-
node.status({fill:"blue",shape:"ring",text:"Uploading training data"});
63-
retrieve_and_rank.createRanker(params, function(err, res) {
64-
handleWatsonCallback(null,node,msg,err,res,function() {
65-
node.status({fill:"blue",shape:"ring",text:"Training data uploaded. Ranker is training"});
66-
//Now check the status of the ranker
67-
var ranker_id = res.ranker_id;
68-
checkRankerStatus(retrieve_and_rank,msg,node,ranker_id);
69-
});;
70-
});
51+
var params = {
52+
training_data: msg.payload
53+
};
54+
55+
if (config.rankername) {
56+
params.training_metadata = "{\"name\": \""+config.rankername+"\"}";
7157
}
72-
createRanker(msg.payload);
73-
//csv training file comes in on msg.payload as a buffer
74-
// var stream_buffer = function (file, contents, cb) {
75-
// fs.writeFile(file, contents, function (err) {
76-
// if (err) throw err;
77-
// cb();
78-
// });
79-
// };
80-
81-
// temp.open({suffix: '.csv'}, function (err, info) {
82-
// if (err) throw err;
83-
// stream_buffer(info.path, msg.payload, function () {
84-
// createRanker(fs.createReadStream(info.path), temp.cleanup);
85-
// });
86-
// });
58+
node.status({fill:"blue",shape:"ring",text:"Uploading training data"});
59+
retrieve_and_rank.createRanker(params, function(err, res) {
60+
handleWatsonCallback(null,node,msg,err,res,function() {
61+
node.status({fill:"blue",shape:"ring",text:"Training data uploaded. Ranker is training"});
62+
//Now check the status of the ranker
63+
var ranker_id = res.ranker_id;
64+
checkRankerStatus(retrieve_and_rank,msg,node,ranker_id);
65+
});;
66+
});
8767
});
8868
});
8969
}
@@ -525,6 +505,7 @@ module.exports = function (RED) {
525505
retrieve_and_rank.rankerStatus(params, function(err, res) {
526506
if (err) {
527507
node.status({});
508+
console.log(err);
528509
var message = "Ranker training state error: "+err.error;
529510
clearInterval(statusInterval);
530511
return node.error(message, msg);

0 commit comments

Comments
 (0)