根据条件更新处理器中的文档
Update document in Processor on the condition based
{
"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;
}
请帮忙!
您正在操作的只是UPDATE文档操作(如果op instanceof DocumentUpdate)。您无权访问存储在索引中的原始文档字段,而只能访问作为 DocumentUpdate 一部分的更新。参见 https://docs.vespa.ai/documentation/document-processing-overview.html
{
"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;
}
请帮忙!
您正在操作的只是UPDATE文档操作(如果op instanceof DocumentUpdate)。您无权访问存储在索引中的原始文档字段,而只能访问作为 DocumentUpdate 一部分的更新。参见 https://docs.vespa.ai/documentation/document-processing-overview.html