Search in sources :

Example 1 with ResultDocument

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();
}
Also used : AssociatedDocument(io.zulia.message.ZuliaBase.AssociatedDocument) ResultDocument(io.zulia.message.ZuliaBase.ResultDocument) Document(org.bson.Document) AssociatedDocument(io.zulia.message.ZuliaBase.AssociatedDocument) ResultDocument(io.zulia.message.ZuliaBase.ResultDocument)

Aggregations

AssociatedDocument (io.zulia.message.ZuliaBase.AssociatedDocument)1 ResultDocument (io.zulia.message.ZuliaBase.ResultDocument)1 Document (org.bson.Document)1