Hi
I’m saving a couple of blobs in a document.
String addJsonDocument(String docId, String json, Map<String, Blob> blobs) {
MutableDocument doc = new MutableDocument(docId, json);
blobs.forEach(doc::setBlob);//"key1",blob1;"key2",blob2
database.save(doc)
}
And when I retrieve the document by “id” I can access the blobs without any problem:
Document docReaded = database.getDocument(id);
Blob blob = docReaded.getBlob("key1");
But when I retrieve several documents from a query I don’t know how to get the blob.
Query listQuery = QueryBuilder.select(SelectResult.all()).from(DataSource.database(database)).where(getWhereExpresion(filter));
ResultSet resultSet = listQuery.execute();
for (Result result : resultSet) {
try {
// In fact, HashMap<String, Object> dictFromJSONstring2 = objectMapper.readValue(arg.getValue().traverse(), HashMap.class);
// Object att = dictFromJSONstring2.get("key1"); return a Map with blob properties, but the blob???
objectMapper.readTree(result.toJSON()).fields()
.forEachRemaining(arg -> ifs.add(objectMapper.convertValue(arg.getValue(), Info.class)));
} catch (JsonProcessingException e) {
.....
}
}
I have noticed that the result is reported, as indicated in the documentation.
{
....
....
....
"key1": {
"length": 2251,
"content_type": "image/jpeg",
"digest": "sha1-xXcns7UvPRgkU42niSw5sFk3xhY=",
"@type": "blob"
}
}
How can I get the blob?
The workaround I am doing is to get the “id” with the query and then launch another query for “id” to get the “Document” but it is slower.
Thank you in advance for any links, notes, advice.