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

我有两个相同数据类型的不同文档,我想根据条件更新状态 detail1 和 detail2

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

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

但是这一切我想在处理器中做。那么,当我无法在处理器中获取字段值时,如何应用检查处理器?

@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;
    }

请帮忙!

4

1 回答 1

3

您仅对 UPDATE 文档操作进行操作(如果 op instanceof DocumentUpdate)。您无权访问存储在索引中的原始文档字段,而只能访问属于 DocumentUpdate 的更新。见https://docs.vespa.ai/documentation/document-processing-overview.html

于 2018-12-05T10:35:04.077 回答