Reputation: 371
Is there any way to auto update any field of document in vespa. Lets I have to update "status" field to 0 when "currentTime" > "expiryTime". I dont want to call any API for that.
"fields": {
"expiryTime": 1543503600000,
"currentTime": 1543503400000,
"status" : 1
}
After currentTime > expireTime, "status" field must be auto updated to 1. "fields": {
"expiryTime": 1543503600000,
"currentTime": 1543503800000,
"status" : 0
}
Upvotes: 0
Views: 203
Reputation: 71
You could also use a Java ExecutorService
to regularly run updates from inside your container, using the document API. I would take care to perform only the needed updates, using a document selection which matches only the documents where the status
should be 0
, and where it isn't already.
In your example, however, the field status
is derived purely from other fields in the same document — perhaps it would be viable to just compute it when needed, using, e.g., a Searcher?
Upvotes: 0
Reputation: 996
I am not sure if I understood your question right then. In your example you have a time-based check that at some point becomes true, and you want to make updates to documents based on this.
This implies some kind of job that runs regularly, does the checks, and runs the update (or whatever) jobs.
Vespa does not have an engine to run jobs. You have to build it yourself - say a cron job that regularly runs vespa-visit with a section criteria, and invokes some code on the documents that match. Or you can run searches regularly to do the same thing.
Upvotes: 0
Reputation: 996
There is no such generic feature - Vespa does not have the equivalent of database triggers, or scheduled maintenance jobs. Quite easy to implement yourself, though, by using vespa-visit and Vespa document processors - select the document space to evaluate and implement update logic in a processor.
For the specific case of removing expired documents, refer to https://docs.vespa.ai/documentation/search-definitions.html#document-expiry
Upvotes: 1