use of io.zulia.message.ZuliaBase.ResultDocument in project zuliasearch by zuliaio.
the class ZuliaIndex method internalStore.
public StoreResponse internalStore(StoreRequest storeRequest) throws Exception {
long timestamp = System.currentTimeMillis();
String uniqueId = storeRequest.getUniqueId();
if (storeRequest.hasResultDocument()) {
ResultDocument resultDocument = storeRequest.getResultDocument();
Document document;
if (!resultDocument.getDocument().isEmpty()) {
document = ZuliaUtil.byteArrayToMongoDocument(resultDocument.getDocument().toByteArray());
} else {
document = new Document();
}
Document metadata;
if (!resultDocument.getMetadata().isEmpty()) {
metadata = ZuliaUtil.byteArrayToMongoDocument(resultDocument.getMetadata().toByteArray());
} else {
metadata = new Document();
}
ZuliaShard s = findShardFromUniqueId(uniqueId);
s.index(uniqueId, timestamp, document, metadata);
}
if (storeRequest.getClearExistingAssociated()) {
documentStorage.deleteAssociatedDocuments(uniqueId);
}
for (AssociatedDocument ad : storeRequest.getAssociatedDocumentList()) {
ad = AssociatedDocument.newBuilder(ad).setTimestamp(timestamp).build();
documentStorage.storeAssociatedDocument(ad);
}
return StoreResponse.newBuilder().build();
}
Aggregations