0
{
  "status":1,
  "expire":15349870000,
  "detail1":"test1",
  "detail2":"test2"
}
{
  "status":0,
  "expire":15349870000,
  "detail1":"test1",
  "detail2":"test2"
}

I have two different documents of same data type, I want to update status, detail1 and detail2 on conditions

if(status==0 and expire > now()) then status = 1 and detail1 = "good"

if(status==1 and expire > now()) then status = 2 and detail2 = "bad"

But all this I want to do in Processor. So how can I apply a check in processor as I am unable to get value of fields in processor?

@Override
    public Progress process(Processing processing) {
        for (DocumentOperation op : processing.getDocumentOperations()) {
            if (op instanceof DocumentUpdate) {
                DocumentUpdate documentUpdate = (DocumentUpdate) op;

if(?){
documentUpdate.addFieldUpdate(FieldUpdate.createAssign(documentUpdate.getDocumentType().getField("detail1"), new StringFieldValue("good")));
}
else if(?){
documentUpdate.addFieldUpdate(FieldUpdate.createAssign(documentUpdate.getDocumentType().getField("detail2"), new StringFieldValue("bad")));
}
            }

        }
        return Progress.DONE;
    }

Please help!

Mohammad Sunny
  • 371
  • 1
  • 3
  • 15

1 Answers1

3

You are operating only on UPDATE document operations (if op instanceof DocumentUpdate). You don't have access to the original document fields stored in the index but only the updates which is part of the DocumentUpdate. See https://docs.vespa.ai/documentation/document-processing-overview.html

Jo Kristian Bergum
  • 2,984
  • 5
  • 8