我能够将元数据与文档一起存储在Watson的Discovery服务中,但现在它已不再有效!发生了什么事?
CreateDocumentRequest.Builder createDocumentBuilder = new CreateDocumentRequest.Builder(environmentId, collectionId);
JsonObject metadata = new JsonObject();
metadata.addProperty("filename", fileName);
createDocumentBuilder.metadata(metadata);
createDocumentBuilder.inputStream(documentStream, applicationString);
CreateDocumentResponse createDocumentResponse = discovery.createDocument(createDocumentBuilder.build()).execute();
{
"matching_results": 1,
"results": [
{
"id": "7c705482-9902-4976-9c77-25fbe92bf7fa",
"score": 1
}
]
}
为什么停止工作?我对这个开始发生的基础框架感到有些失望。把它集合在一起IBM!
答案 0 :(得分:0)
我修正了你的错误IBM。
在com.ibm.watson.developer_cloud.discovery.v1.Discovery.createDocument(CreateDocumentRequest createRequest)中,您可以看到正在构建的Multipart请求,而从不添加所需的元数据部分(smh)。
我扩展了Discovery并添加了
% First Particle
N1 = 100;
particle1 = struct();
particle1.x = cumsum( randn(N1, 1) );
particle1.y = cumsum( randn(N1, 1) );
% Second Particle
N2 = 200;
particle2 = struct();
particle2.x = cumsum( randn(N2, 1) );
particle2.y = cumsum( randn(N2, 1) );
% Plot
figure;
hold on
plot(particle1.x, particle1.y, 'r');
plot(particle2.x, particle2.y, 'b');
ylabel('Y Position');
xlabel('X Position');
title('position versus time in 2D');
到请求...
multipartBuilder.addFormDataPart("metadata", createRequest.getMetadata().toString());