Vespa

Vespa

Certified

Tasks that query Vespa, the search and vector engine, with YQL for text, vector and hybrid search, read documents by their ID, delete documents by ID or by selection, and feed documents in bulk.

Provide the Vespa endpoint, and a data-plane token for Vespa Cloud, to run YQL queries and read the hits as rows, the first hit only or just the match count, or store them in an ION file (fetch type), with a rank profile, query tensors and any other query API parameter; read one document by its ID; or delete one document by its ID, or every document a selection matches once allowSelection is set; or feed many documents at once (put, update or remove), with the failed records in a file.

How to use the Vespa plugin

Query a Vespa application from Kestra flows with YQL (text, vector and hybrid search), read documents by their ID, delete documents by ID or by selection, feed many documents at once, and start a flow when new documents match a query.

Authentication

Set endpoint to the base URL of the Vespa container cluster, like http://localhost: 8080 or a Vespa Cloud endpoint. For Vespa Cloud, set token to a data-plane token, sent as a bearer token; leave it unset for a self-hosted Vespa without authentication. Store the token in a secret, and set the connection once for every task with plugin defaults.

Tasks

Query runs one YQL query (yql) on Vespa's query API and returns the hits of that one answer. Optional: query (text for userQuery()), hits, offset, ranking (rank profile), queryTimeout (Vespa's own time limit) and parameters for any other query API parameter, like a query tensor input.query(q). A parameter that a task property also sets fails the task, so each value has one place.

Rows keep Vespa's hit shape: id, relevance and the document under fields, read like {{ outputs.search.rows[0].fields.album }}. fetchType picks FETCH (rows, default), FETCH_ONE (first row), STORE (the rows in an ION file in Kestra's internal storage, returned as uri, for the next task to read) or NONE (only totalCount). Vespa returns 10 hits by default and refuses more than 400 hits or an offset over 1000 unless the application raises its limits. Query, Get, Delete and the trigger read at most 32 MiB of a Vespa answer and fail on a bigger one: check that endpoint points to Vespa, and for a query ask for fewer hits or summary fields.

Get reads one document by its full ID (documentId, like id: mynamespace: music: : kind-of-blue, or with a n=<number> or g=<group> part) from Vespa's document API and returns id and document, the document's fields. A Query hit's id can be passed straight in when the hit carries the document ID, as with select *. A document that doesn't exist gives a null document; set errorOnMissing: true to fail the task instead.

Delete removes one document by its full ID (documentId, same format as Get), or every document a document selection matches (selection, like music.artist == "Miles Davis") in the content cluster cluster. Set exactly one of documentId and selection. A delete by selection fails before sending anything unless allowSelection: true, since selection: true matches every document, except those of a global document type (global="true"), which a selection doesn't reach. Vespa deletes in chunks of up to 60 seconds each; with readTimeout set, each chunk is kept to half of it. Once Vespa has deleted documents, a failure names how many were already removed. It returns deleted, the number of documents removed; for a delete by ID Vespa answers the same whether the document existed, so deleted is null and a mistyped ID succeeds without removing anything.

Feed writes (PUT, default), updates (UPDATE, with fields in Vespa's update format) or removes (REMOVE) many documents through Vespa's feed client, which retries throttled answers. from takes the records inline or as a kestra:// file from a previous task (Kestra reads that file whole into memory before the first record is sent, so split very large files); each record is a map with id and fields (REMOVE needs only id). An id that starts with id: is the full document ID; any other id is a key, completed with namespace and documentType. It returns successCount and failureCount. A record Vespa refuses fails the task once the others are written; with failOnError: false the task ends in WARNING and uri holds the failed records, each row with the record as given and its error. Each operation gets readTimeout (5 minutes when unset); one that runs out may still have been applied by Vespa. connectTimeout doesn't apply to Feed, and its endpoint must have no path (only scheme, host and port): the feed client always sends to the host's root. Before feeding, Feed sends one HEAD /state/v1/health through Kestra's HTTP client, so Kestra's allowed and denied hosts (kestra.tasks.http.allowed-list and denied-list, from Kestra 2.0) apply to it too.

createIfNotExists: true turns an UPDATE of a missing document into an upsert. condition is Vespa's test-and-set condition, like music.year==2000: a record whose document doesn't match, or doesn't exist, is a failed record. With both, a missing document is written without checking the condition; Vespa also writes it when every replica of an existing document is unreachable (Vespa's warning). maxInFlight (1 to 4096, default 4096) caps the records waiting for Vespa's answer, to put less load on Vespa.

Triggers

Trigger runs a YQL query (yql) every interval (default 60 seconds) and starts the flow with the documents it hasn't delivered before, as trigger.rows in the same shape as Query, or in an ION file at trigger.uri with fetchType: STORE. watermarkField names an int or long attribute that grows with every write, like the time the document was fed: the trigger keeps the highest value it delivered, and the document IDs at that value, in the namespace KV store, and asks Vespa only for documents at or above it, oldest first, through Vespa's recall and sorting parameters, so the YQL is sent as written. The first poll delivers what already matches, up to hits (default 100) per poll, so a large backlog arrives over several polls.

  • trigger.size is how many documents were delivered; trigger.totalCount is Vespa's count for the poll, which includes the documents already delivered at the watermark value.
  • Never delivered: a document written later with a lower watermarkField value, and a document without a value. A removed document fires nothing, and an attribute of another type than int or long matches nothing.
  • Each hit must carry its document ID and the watermarkField value, as select * does; the poll fails when no hit carries the field.
  • The YQL can't have an order by, an offset, a limit (the same words inside quoted text are fine) or a grouping.
  • Keep the field fine-grained (like milliseconds) and hits well under Vespa's maxHits (400 by default): once more documents share the highest value than maxHits leaves room for, the poll fails with a message saying what to change.
  • The watermark lives in the flow's namespace KV store under vespa_trigger_watermark_<flow id length>_<flow id>_<trigger id length>_<trigger id> and outlives the flow: delete that key to start over. Changing watermarkField also starts over, from the lowest value of the new field.
  • If Vespa searched only part of the corpus, the poll delivers nothing and the next one tries again.
  • On Kestra 2.0 with allowConcurrent: true a slow poll can overlap the next one and deliver the same documents twice.