-
Notifications
You must be signed in to change notification settings - Fork 668
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[discovery] document additions fail #369
Comments
Hi @kognate thanks for the fix, but I just had a similar issue now, here is my code snippet discovery.addDocument({
environment_id: 'env-id-here',
collection_id: 'coll-id-here',
configuration_id: 'config-id-here',
metadata:'{"Content-Type":"application/json"}',
file:Buffer.from("HERE IS MY TEST TEXT", 'utf8')
}, function(err, data) {
if (err) {
console.error(err);
} else {
console.log(JSON.stringify(data, null, 2));
}
}); and I get the following error
I checked in the sdk and I could see that this fix merged above is there.Any ideas why this is still happening? |
bumpppppp This issue isn't fixed. Not sure why its closed. |
Any update on this guys? Why is this issue closed? the issue is still there. |
Hey, sorry this got dropped, we had some internal shuffling around. I think #474 was actually a duplicate of this, and as of v2.34.0, JSON documents should work either by specifying a var document_obj = {
environment_id: environment,
collection_id: collection,
file: {"foo": "bar"}
};
discovery.addJsonDocument(document_obj, function (err, response) {
if (err) {
console.error(err);
} else {
console.log(JSON.stringify(response, null, 2));
}
}); Can you test and confirm? There's also an open ticket to add a matching updateJsonDocument method - #477 - that will hopefully be implemented soon. In the meanwhile, you can specify a |
Oh, and to respond to @manyike's code sample, I just noticed that it says As mentioned above, the service ignores content-type headers & metadata, and instead checks only the file extension and the content itself. The filename defaults to To specify the filename with a Buffer, set the discovery.addDocument({
environment_id: 'env-id-here',
collection_id: 'coll-id-here',
configuration_id: 'config-id-here',
file: {
value: Buffer.from("JSON goes here", 'utf8'),
options: {
filename: 'whatever.json'
}
}
}, function(err, data) {
if (err) {
console.error(err);
} else {
console.log(JSON.stringify(data, null, 2));
}
}); |
This was reported internally and on SO. https://stackoverflow.com/questions/41473388/create-new-document-in-ibm-watson-discovery-service-with-watson-developer-cloud
There is a bug in the discovery add document code.
The text was updated successfully, but these errors were encountered: