Search in sources :

Example 1 with FetchType

use of io.zulia.message.ZuliaQuery.FetchType in project zuliasearch by zuliaio.

the class ZuliaIndex method fetch.

public ZuliaServiceOuterClass.FetchResponse fetch(ZuliaServiceOuterClass.FetchRequest fetchRequest) throws Exception {
    ZuliaServiceOuterClass.FetchResponse.Builder frBuilder = ZuliaServiceOuterClass.FetchResponse.newBuilder();
    String uniqueId = fetchRequest.getUniqueId();
    FetchType resultFetchType = fetchRequest.getResultFetchType();
    if (!FetchType.NONE.equals(resultFetchType)) {
        ZuliaBase.ResultDocument resultDoc = getSourceDocument(uniqueId, resultFetchType, fetchRequest.getDocumentFieldsList(), fetchRequest.getDocumentMaskedFieldsList());
        if (null != resultDoc) {
            frBuilder.setResultDocument(resultDoc);
        }
    }
    FetchType associatedFetchType = fetchRequest.getAssociatedFetchType();
    if (!FetchType.NONE.equals(associatedFetchType)) {
        if (!fetchRequest.getFilename().isEmpty()) {
            AssociatedDocument ad = getAssociatedDocument(uniqueId, fetchRequest.getFilename(), associatedFetchType);
            if (ad != null) {
                frBuilder.addAssociatedDocument(ad);
            }
        } else {
            for (AssociatedDocument ad : getAssociatedDocuments(uniqueId, associatedFetchType)) {
                frBuilder.addAssociatedDocument(ad);
            }
        }
    }
    return frBuilder.build();
}
Also used : AssociatedDocument(io.zulia.message.ZuliaBase.AssociatedDocument) FetchType(io.zulia.message.ZuliaQuery.FetchType) ZuliaBase(io.zulia.message.ZuliaBase) ResultDocument(io.zulia.message.ZuliaBase.ResultDocument)

Aggregations

ZuliaBase (io.zulia.message.ZuliaBase)1 AssociatedDocument (io.zulia.message.ZuliaBase.AssociatedDocument)1 ResultDocument (io.zulia.message.ZuliaBase.ResultDocument)1 FetchType (io.zulia.message.ZuliaQuery.FetchType)1