Reference API

vespa.application

Vespa

class vespa.application.Vespa(url: str, port: int | None = None, deployment_message: ~typing.List[str] | None = None, cert: str | None = None, key: str | None = None, vespa_cloud_secret_token: str | None = None, output_file: ~typing.IO = <_io.TextIOWrapper name='<stdout>' mode='w' encoding='utf-8'>, application_package: ~vespa.package.ApplicationPackage | None = None)
__init__(url: str, port: int | None = None, deployment_message: ~typing.List[str] | None = None, cert: str | None = None, key: str | None = None, vespa_cloud_secret_token: str | None = None, output_file: ~typing.IO = <_io.TextIOWrapper name='<stdout>' mode='w' encoding='utf-8'>, application_package: ~vespa.package.ApplicationPackage | None = None) None

Establish a connection with an existing Vespa application.

Parameters:
  • url – Vespa endpoint URL.

  • port – Vespa endpoint port.

  • deployment_message – Message returned by Vespa engine after deployment. Used internally by deploy methods.

  • cert – Path to data plane certificate and key file in case the ‘key’ parameter is none. If ‘key’ is not None, this should be the path of the certificate file. Typically generated by Vespa-cli with ‘vespa auth cert’

  • key – Path to the data plane key file. Typically generated by Vespa-cli with ‘vespa auth cert’

  • vespa_cloud_secret_token – Vespa Cloud data plane secret token.

  • output_file – Output file to write output messages.

  • application_package – Application package definition used to deploy the application.

>>> Vespa(url = "https://cord19.vespa.ai")  
>>> Vespa(url = "http://localhost", port = 8080)
Vespa(http://localhost, 8080)
>>> Vespa(url="https://token-endpoint..z.vespa-app.cloud", vespa_cloud_secret_token="vespa_cloud_secret_token") 
>>> Vespa(url = "https://mtls-endpoint..z.vespa-app.cloud", cert = "/path/to/cert.pem", key = "/path/to/key.pem")  
property application_package

Get application package definition, if available.

asyncio(connections: int | None = 8, total_timeout: int = 10) VespaAsync

Access Vespa asynchronous connection layer

Parameters:
  • connections – Number of allowed concurrent connections

  • total_timeout – Total timeout in secs.

Returns:

Instance of Vespa asynchronous layer.

delete_all_docs(content_cluster_name: str, schema: str, namespace: str | None = None, slices: int = 1, **kwargs) Response

Delete all documents associated with the schema. This might block for a long time as it requires sending multiple delete requests to complete.

Parameters:
  • content_cluster_name – Name of content cluster to GET from, or visit.

  • schema – The schema that we are deleting data from.

  • namespace – The namespace that we are deleting data from. If no namespace is provided the schema is used.

  • slices – Number of slices to use for parallel delete requests. Defaults to 1.

  • kwargs – Additional arguments to be passed to the HTTP DELETE request https://docs.vespa.ai/en/reference/document-v1-api-reference.html#request-parameters

Returns:

Response of the HTTP DELETE request.

delete_data(schema: str, data_id: str, namespace: str | None = None, groupname: str | None = None, **kwargs) VespaResponse

Delete a data point from a Vespa app.

Parameters:
  • schema – The schema that we are deleting data from.

  • data_id – Unique id associated with this data point.

  • namespace – The namespace that we are deleting data from. If no namespace is provided the schema is used.

  • groupname – The groupname that we are deleting data from.

  • kwargs – Additional arguments to be passed to the HTTP DELETE request https://docs.vespa.ai/en/reference/document-v1-api-reference.html#request-parameters

Returns:

Response of the HTTP DELETE request.

feed_data_point(schema: str, data_id: str, fields: Dict, namespace: str | None = None, groupname: str | None = None, **kwargs) VespaResponse

Feed a data point to a Vespa app. Will create a new VespaSync with connection overhead. ` with VespaSync(app) as sync_app: sync_app.feed_data_point(...) `

Parameters:
  • schema – The schema that we are sending data to.

  • data_id – Unique id associated with this data point.

  • fields – Dict containing all the fields required by the schema.

  • namespace – The namespace that we are sending data to.

  • groupname – The groupname that we are sending data

Returns:

VespaResponse of the HTTP POST request.

feed_iterable(iter: Iterable[Dict], schema: str | None = None, namespace: str | None = None, callback: Callable | None = None, operation_type: str | None = 'feed', max_queue_size: int = 1000, max_workers: int = 8, max_connections: int = 16, **kwargs)

Feed data from an Iterable of Dict with the keys ‘id’ and ‘fields’ to be used in the feed_data_point().

Uses a queue to feed data in parallel with a thread pool. The result of each operation is forwarded to the user provided callback function that can process the returned VespaResponse.

Parameters:
  • iter – An iterable of Dict containing the keys ‘id’ and ‘fields’ to be used in the feed_data_point().

  • schema – The Vespa schema name that we are sending data to.

  • namespace – The Vespa document id namespace. If no namespace is provided the schema is used.

  • callback – A callback function to be called on each result. Signature callback(response:VespaResponse, id:str)

  • operation_type – The operation to perform. Default to feed. Valid are feed, update or delete.

  • max_queue_size – The maximum size of the blocking queue and max in-flight operations.

  • max_workers – The maximum number of workers in the threadpool executor.

  • max_connections – The maximum number of persisted connections to the Vespa endpoint.

  • kwargs – Additional parameters are passed to the respective operation type specific _data_point().

get_application_status() Response | None

Get application status (/ApplicationStatus)

Returns:

get_data(schema: str, data_id: str, namespace: str | None = None, groupname: str | None = None, raise_on_not_found: bool | None = False, **kwargs) VespaResponse

Get a data point from a Vespa app.

Parameters:
  • data_id – Unique id associated with this data point.

  • schema – The schema that we are getting data from. Will attempt to infer schema name if not provided.

  • data_id – Unique id associated with this data point.

  • namespace – The namespace that we are getting data from. If no namespace is provided the schema is used.

  • groupname – The groupname that we are getting data from.

  • raise_on_not_found – Raise an exception if the data_id is not found. Default is False.

  • kwargs – Additional arguments to be passed to the HTTP GET request https://docs.vespa.ai/en/reference/document-v1-api-reference.html#request-parameters

Returns:

Response of the HTTP GET request.

get_document_v1_path(id: str, schema: str | None = None, namespace: str | None = None, group: str | None = None, number: str | None = None) str

Convert to document v1 path

Parameters:
  • id – The id of the document

  • namespace – The namespace of the document

  • schema – The schema of the document

  • group – The group of the document

  • number – The number of the document

Returns:

The path to the document v1 endpoint

get_model_endpoint(model_id: str | None = None) Response | None

Get stateless model evaluation endpoints.

get_model_from_application_package(model_name: str)

Get model definition from application package, if available.

predict(x, model_id, function_name='output_0')

Obtain a stateless model evaluation.

Parameters:
  • x – Input where the format depends on the task that the model is serving.

  • model_id – The id of the model used to serve the prediction.

  • function_name – The name of the output function to be evaluated.

Returns:

Model prediction.

query(body: Dict | None = None, groupname: str | None = None, **kwargs) VespaQueryResponse

Send a query request to the Vespa application.

Send ‘body’ containing all the request parameters.

Parameters:
  • body – Dict containing request parameters.

  • groupname – The groupname used with streaming search.

param kwargs: Extra Vespa Query API parameters. :return: The response from the Vespa application.

syncio(connections: int | None = 8) VespaSync

Access Vespa synchronous connection layer

Parameters:
  • connections – Number of allowed concurrent connections

  • total_timeout – Total timeout in secs.

Returns:

Instance of Vespa asynchronous layer.

update_data(schema: str, data_id: str, fields: Dict, create: bool = False, namespace: str | None = None, groupname: str | None = None, **kwargs) VespaResponse

Update a data point in a Vespa app.

Parameters:
  • schema – The schema that we are updating data.

  • data_id – Unique id associated with this data point.

  • fields – Dict containing all the fields you want to update.

  • create – If true, updates to non-existent documents will create an empty document to update

  • namespace – The namespace that we are updating data. If no namespace is provided the schema is used.

  • groupname – The groupname that we are updating data.

  • kwargs – Additional arguments to be passed to the HTTP PUT request. https://docs.vespa.ai/en/reference/document-v1-api-reference.html#request-parameters

Returns:

Response of the HTTP PUT request.

wait_for_application_up(max_wait: int) None

Wait for application endpoint ready (/ApplicationStatus).

Parameters:

max_wait – Seconds to wait for the application endpoint

Raises:

RuntimeError – If not able to reach endpoint within :max_wait: param or the client fails to authenticate.

Returns:

VespaSync

class vespa.application.VespaSync(app: Vespa, pool_maxsize: int = 10, pool_connections=10)
__init__(app: Vespa, pool_maxsize: int = 10, pool_connections=10) None
delete_all_docs(content_cluster_name: str, schema: str, namespace: str | None = None, slices: int = 1, **kwargs) None

Delete all documents associated with the schema.

Parameters:
Returns:

Response of the HTTP DELETE request.

Raises:

HTTPError – if one occurred

delete_data(schema: str, data_id: str, namespace: str | None = None, groupname: str | None = None, **kwargs) VespaResponse

Delete a data point from a Vespa app.

Parameters:
Returns:

Response of the HTTP DELETE request.

Raises:

HTTPError – if one occurred

feed_data_point(schema: str, data_id: str, fields: Dict, namespace: str | None = None, groupname: str | None = None, **kwargs) VespaResponse

Feed a data point to a Vespa app.

Parameters:
  • schema – The schema that we are sending data to.

  • data_id – Unique id associated with this data point.

  • fields – Dict containing all the fields required by the schema.

  • namespace – The namespace that we are sending data to. If no namespace is provided the schema is used.

  • groupname – The group that we are sending data to.

  • kwargs – Additional HTTP request parameters (https://docs.vespa.ai/en/reference/document-v1-api-reference.html#request-parameters)

Returns:

Response of the HTTP POST request.

Raises:

HTTPError – if one occurred

get_data(schema: str, data_id: str, namespace: str | None = None, groupname: str | None = None, raise_on_not_found: bool | None = False, **kwargs) VespaResponse

Get a data point from a Vespa app.

Parameters:
Returns:

Response of the HTTP GET request.

Raises:

HTTPError – if one occurred

get_model_endpoint(model_id: str | None = None) dict | None

Get model evaluation endpoints.

predict(model_id, function_name, encoded_tokens)

Obtain a stateless model evaluation.

Parameters:
  • model_id – The id of the model used to serve the prediction.

  • function_name – The name of the output function to be evaluated.

  • encoded_tokens – URL-encoded input to the model

Returns:

Model prediction.

query(body: Dict | None = None, groupname: str | None = None, **kwargs) VespaQueryResponse

Send a query request to the Vespa application.

Send ‘body’ containing all the request parameters.

Parameters:
Returns:

Either the request body if debug_request is True or the result from the Vespa application

Raises:

HTTPError – if one occurred

update_data(schema: str, data_id: str, fields: Dict, create: bool = False, namespace: str | None = None, groupname: str | None = None, **kwargs) VespaResponse

Update a data point in a Vespa app.

Parameters:
  • schema – The schema that we are updating data.

  • data_id – Unique id associated with this data point.

  • fields – Dict containing all the fields you want to update.

  • create – If true, updates to non-existent documents will create an empty document to update

  • namespace – The namespace that we are updating data.

  • groupname – The groupname used to update data

  • kwargs – Additional HTTP request parameters (https://docs.vespa.ai/en/reference/document-v1-api-reference.html#request-parameters)

Returns:

Response of the HTTP PUT request.

Raises:

HTTPError – if one occurred

VespaAsync

class vespa.application.VespaAsync(app: Vespa, connections: int | None = 10, total_timeout: int = 180)
__init__(app: Vespa, connections: int | None = 10, total_timeout: int = 180) None

Utility functions

vespa.application.raise_for_status(response: Response, raise_on_not_found: bool | None = False) None

Raises an appropriate error if necessary.

If the response contains an error message, VespaError is raised along with HTTPError to provide more details.

Parameters:
  • response – Response object from Vespa API.

  • raise_on_not_found – If True, raise HTTPError if status_code is 404.

Raises:
  • HTTPError – If status_code is between 400 and 599.

  • VespaError – If the response JSON contains an error message.

vespa.deployment

VespaDeployment

class vespa.deployment.VespaDeployment
read_app_package_from_disk(application_root: Path) bytes

Read the contents of an application package on disk into a zip file.

Parameters:

application_root – Application package directory root

Returns:

The zipped application package as bytes.

VespaDocker

class vespa.deployment.VespaDocker(port: int = 8080, container_memory: str | int = 4294967296, output_file: ~typing.IO = <_io.TextIOWrapper name='<stdout>' mode='w' encoding='utf-8'>, container: ~docker.models.containers.Container | None = None, container_image: str = 'vespaengine/vespa', volumes: ~typing.List[str] | None = None, cfgsrv_port: int = 19071, debug_port: int = 5005)
__init__(port: int = 8080, container_memory: str | int = 4294967296, output_file: ~typing.IO = <_io.TextIOWrapper name='<stdout>' mode='w' encoding='utf-8'>, container: ~docker.models.containers.Container | None = None, container_image: str = 'vespaengine/vespa', volumes: ~typing.List[str] | None = None, cfgsrv_port: int = 19071, debug_port: int = 5005) None

Manage Docker deployments.

Parameters:
  • port – Container port.

  • cfgsrv_port – Config Server port.

  • debug_port – Port to connect to, to debug the vespa container.

  • output_file – Output file to write output messages.

  • container_memory – Docker container memory available to the application.

  • container – Used when instantiating VespaDocker from a running container.

  • volumes – A list of strings which each one of its elements specifies a mount volume. For example: [‘/home/user1/:/mnt/vol2’,’/var/www:/mnt/vol1’].

  • container_image – Docker container image.

deploy(application_package: ApplicationPackage, debug: bool = False) Vespa

Deploy the application package into a Vespa container.

Parameters:
  • application_package – ApplicationPackage to be deployed.

  • debug – Add the configured debug_port to the docker port mapping.

Returns:

a Vespa connection instance.

deploy_from_disk(application_name: str, application_root: Path, debug: bool = False) Vespa

Deploy from a directory tree. Used when making changes to application package files not supported by pyvespa - this is why this method is not found in the ApplicationPackage class.

Parameters:
  • application_name – Application package name.

  • application_root – Application package directory root

  • debug – Add the configured debug_port to the docker port mapping.

Returns:

a Vespa connection instance.

static from_container_name_or_id(name_or_id: str, output_file: ~typing.IO = <_io.TextIOWrapper name='<stdout>' mode='w' encoding='utf-8'>) VespaDocker

Instantiate VespaDocker from a running container.

Parameters:
  • name_or_id – Name or id of the container.

  • output_file – Output file to write output messages.

Raises:

ValueError – Exception if container not found

Returns:

VespaDocker instance associated with the running container.

restart_services() None

Restart Vespa services inside the docker image, it is equivalent to calling self.stop_services() followed by self.start_services().

Raises:

RuntimeError – if a container has not been set

Returns:

None

start_services() None

Start Vespa services inside the docker image, first waiting for the Config Server, then for other services.

Raises:

RuntimeError – if a container has not been set

Returns:

None

stop_services() None

Stop Vespa services inside the docker image, first stopping the services, then stopping the Config Server.

Raises:

RuntimeError – if a container has not been set

Returns:

None

wait_for_config_server_start(max_wait: int) None

Waits for Config Server to start inside the Docker image

Parameters:

max_wait – Seconds to wait for the application endpoint

Raises:

RuntimeError – Raises runtime error if the config server does not start within max_wait

Returns:

VespaCloud

class vespa.deployment.VespaCloud(tenant: str, application: str, application_package: ~vespa.package.ApplicationPackage, key_location: str | None = None, key_content: str | None = None, auth_client_token_id: str | None = None, output_file: ~typing.IO = <_io.TextIOWrapper name='<stdout>' mode='w' encoding='utf-8'>)
__init__(tenant: str, application: str, application_package: ~vespa.package.ApplicationPackage, key_location: str | None = None, key_content: str | None = None, auth_client_token_id: str | None = None, output_file: ~typing.IO = <_io.TextIOWrapper name='<stdout>' mode='w' encoding='utf-8'>) None

Deploy application to the Vespa Cloud (cloud.vespa.ai)

Parameters:
  • tenant – Tenant name registered in the Vespa Cloud.

  • application – Application name in the Vespa Cloud.

  • application_package – ApplicationPackage to be deployed.

  • key_location – Location of the control plane key used for signing HTTP requests to the Vespa Cloud.

  • key_content – Content of the control plane key used for signing HTTP requests to the Vespa Cloud. Use only when key file is not available.

  • auth_client_token_id – Use token based data plane authentication. This is the token name configured in the Vespa Cloud Console. This is used to configure Vespa services.xml. The token is given read and write permissions.

  • output_file – Output file to write output messages. Default is sys.stdout

delete(instance: str | None = 'default') None

Delete the specified instance from the dev environment in the Vespa Cloud.

Parameters:

instance – Name of the instance to delete.

Returns:

deploy(instance: str | None = 'default', disk_folder: str | None = None) Vespa

Deploy the given application package as the given instance in the Vespa Cloud dev environment.

Parameters:
  • instance – Name of this instance of the application, in the Vespa Cloud.

  • disk_folder – Disk folder to save the required Vespa config files. Default to application name folder within user’s current working directory.

Returns:

a Vespa connection instance.

deploy_from_disk(instance: str, application_root: Path) Vespa

Deploy from a directory tree. Used when making changes to application package files not supported by pyvespa. NB: Requires certificate and key to be generated with ‘vespa auth cert’.

Parameters:
  • instance – Name of the instance where the application is to be run

  • application_root – Application package directory root

Returns:

a Vespa connection instance.

vespa.exceptions

VespaError

class vespa.exceptions.VespaError

Vespa returned an error response

vespa.io

VespaQueryResponse

class vespa.io.VespaQueryResponse(json, status_code, url, request_body=None)
__init__(json, status_code, url, request_body=None) None
get_json() Dict

For debugging when the response does not have hits.

Returns:

JSON object with full response

VespaResponse

class vespa.io.VespaResponse(json: Dict, status_code: int, url: str, operation_type: str)

Class to represent a Vespa HTTP API response.

__init__(json: Dict, status_code: int, url: str, operation_type: str) None
get_json() Dict

Return json of the response.

get_status_code() int

Return status code of the response.

is_successful() bool

True if status code is 200.

is_successfull() bool

[Deprecated] Use is_successful() instead

Utility functions

vespa.package

ApplicationPackage

class vespa.package.ApplicationPackage(name: str, schema: List[Schema] | None = None, query_profile: QueryProfile | None = None, query_profile_type: QueryProfileType | None = None, stateless_model_evaluation: bool = False, create_schema_by_default: bool = True, create_query_profile_by_default: bool = True, configurations: List[ApplicationConfiguration] | None = None, validations: List[Validation] | None = None, components: List[Component] | None = None, auth_clients: List[AuthClient] | None = None)
__init__(name: str, schema: List[Schema] | None = None, query_profile: QueryProfile | None = None, query_profile_type: QueryProfileType | None = None, stateless_model_evaluation: bool = False, create_schema_by_default: bool = True, create_query_profile_by_default: bool = True, configurations: List[ApplicationConfiguration] | None = None, validations: List[Validation] | None = None, components: List[Component] | None = None, auth_clients: List[AuthClient] | None = None) None

Create an Application Package. An ApplicationPackage instance comes with a default Schema that contains a default Document

Parameters:
  • name – Application name. Cannot contain ‘-’ or ‘_’.

  • schema – List of Schema`s of the application. If `None, an empty Schema with the same name of the application will be created by default.

  • query_profileQueryProfile of the application. If None, a QueryProfile named default with QueryProfileType named root will be created by default.

  • query_profile_typeQueryProfileType of the application. If None, a empty QueryProfileType named root will be created by default.

  • stateless_model_evaluation – Enable stateless model evaluation. Default to False.

  • create_schema_by_default – Include a Schema with the same name as the application if no Schema is provided in the schema argument.

  • create_query_profile_by_default – Include a default QueryProfile and QueryProfileType in case it is not explicitly defined by the user in the query_profile and query_profile_type parameters.

  • configurations – List of ApplicationConfiguration that contains configurations for the application.

  • validations – Optional list of Validation to be overridden.

  • components – List of Component that contains configurations for application components.

  • clients – List of Client that contains configurations for client authorization.

The easiest way to get started is to create a default application package:

>>> ApplicationPackage(name="testapp")
ApplicationPackage('testapp', [Schema('testapp', Document(None, None, None), None, None, [], False, None, [], None)], QueryProfile(None), QueryProfileType(None))

It will create a default Schema, QueryProfile and QueryProfileType that you can then populate with specifics of your application.

add_schema(*schemas: Schema) None

Add Schema’s to the application package.

Parameters:

schemas – schemas to be added

Returns:

to_files(root: Path) None

Export the application package as a directory tree.

Parameters:

root – Directory to export files to

Returns:

to_zip() BytesIO

Return the application package as zipped bytes, to be used in a subsequent deploy :return: BytesIO buffer

to_zipfile(zfile: Path) None

Export the application package as a deployable zipfile. See application packages for deployment options.

Parameters:

zfile – Filename to export to

Returns:

ApplicationConfiguration

class vespa.package.ApplicationConfiguration(name: str, value: str | Dict[str, Dict | str])
__init__(name: str, value: str | Dict[str, Dict | str]) str

Create a Vespa Schema.

Check the Config documentation for more detailed information about generic configuration.

Parameters:
  • name – Configuration name.

  • value – Either a string or a Dict (it may be a nested dict) of values.

Example:

>>> ApplicationConfiguration(
...     name="container.handler.observability.application-userdata",
...     value={"version": "my-version"}
... )
ApplicationConfiguration(name="container.handler.observability.application-userdata")

Document

class vespa.package.Document(fields: List[Field] | None = None, inherits: str | None = None, structs: List[Struct] | None = None)
__init__(fields: List[Field] | None = None, inherits: str | None = None, structs: List[Struct] | None = None) None

Create a Vespa Document.

Check the Vespa documentation for more detailed information about documents.

Parameters:

fields – A list of Field to include in the document’s schema.

To create a Document:

>>> Document()
Document(None, None, None)
>>> Document(fields=[Field(name="title", type="string")])
Document([Field('title', 'string', None, None, None, None, None, None, None, None, True, None, None, None, [], None)], None, None)
>>> Document(fields=[Field(name="title", type="string")], inherits="context")
Document([Field('title', 'string', None, None, None, None, None, None, None, None, True, None, None, None, [], None)], context, None)
add_fields(*fields: Field) None

Add Field’s to the document.

Parameters:

fields – fields to be added

Returns:

add_structs(*structs: Struct) None

Add Struct’s to the document.

Parameters:

structs – structs to be added

Returns:

DocumentSummary

class vespa.package.DocumentSummary(name: str, inherits: str | None = None, summary_fields: List[Summary] | None = None, from_disk: Literal[True] | None = None, omit_summary_features: Literal[True] | None = None)
__init__(name: str, inherits: str | None = None, summary_fields: List[Summary] | None = None, from_disk: Literal[True] | None = None, omit_summary_features: Literal[True] | None = None) None

Create a Document Summary. Check the Vespa documentation for more detailed information about documment-summary.

Parameters:
  • name – Name of the document-summary.

  • inherits – Name of another document-summary from which this inherits from.

  • summary_fields – List of summaries used in this document-summary.

  • from_disk – Marks this document-summary as accessing fields on disk.

  • omit_summary_features – Specifies that summary-features should be omitted from this document summary.

>>> DocumentSummary(
...     name="document-summary",
... )
DocumentSummary('document-summary', None, None, None, None)
>>> DocumentSummary(
...     name="which-inherits",
...     inherits="base-document-summary",
... )
DocumentSummary('which-inherits', 'base-document-summary', None, None, None)
>>> DocumentSummary(
...     name="with-field",
...     summary_fields=[Summary("title", "string", [("source", "title")])]
... )
DocumentSummary('with-field', None, [Summary('title', 'string', [('source', 'title')])], None, None)
>>> DocumentSummary(
...     name="with-bools",
...     from_disk=True,
...     omit_summary_features=True,
... )
DocumentSummary('with-bools', None, None, True, True)

Field

class vespa.package.Field(name: str, type: str, indexing: ~typing.List[str] | None = None, index: str | None = None, attribute: ~typing.List[str] | None = None, ann: ~vespa.package.HNSW | None = None, match: ~typing.List[str | ~typing.Tuple[str, str]] | None = None, weight: int | None = None, bolding: ~typing.Literal[True] | None = None, summary: ~vespa.package.Summary | None = None, is_document_field: bool | None = True, **kwargs: ~typing_extensions.)
__init__(name: str, type: str, indexing: ~typing.List[str] | None = None, index: str | None = None, attribute: ~typing.List[str] | None = None, ann: ~vespa.package.HNSW | None = None, match: ~typing.List[str | ~typing.Tuple[str, str]] | None = None, weight: int | None = None, bolding: ~typing.Literal[True] | None = None, summary: ~vespa.package.Summary | None = None, is_document_field: bool | None = True, **kwargs: ~typing_extensions.) None

Create a Vespa field.

Check the Vespa documentation for more detailed information about fields.

Once we have an ApplicationPackage instance containing a Schema and a Document, we usually want to add fields so that we can store our data in a structured manner. We can accomplish that by creating Field instances and adding those to the ApplicationPackage instance via Schema and Document methods.

Parameters:
  • name – Field name.

  • type – Field data type.

  • indexing – Configures how to process data of a field during indexing.

  • index – Sets index parameters. Content in fields with index are normalized and tokenized by default.

  • attribute – Specifies a property of an index structure attribute.

  • ann – Add configuration for approximate nearest neighbor.

  • match – Set properties that decide how the matching method for this field operate.

  • weight – Sets the weight of the field, using when calculating Rank Scores.

  • bolding – Whether to highlight matching query terms in the summary.

  • summary – Add configuration for summary of the field.

  • is_document_field – Whether the field is a document field or part of the schema. True by default.

Key stemming:

Add configuration for stemming of the field.

Key rank:

Add configuration for ranking calculations of the field.

Key query_command:

Add configuration for query-command of the field.

Key struct_fields:

Add struct-fields to the field.

Key alias:

Add alias to the field.

>>> Field(name = "title", type = "string", indexing = ["index", "summary"], index = "enable-bm25")
Field('title', 'string', ['index', 'summary'], 'enable-bm25', None, None, None, None, None, None, True, None, None, None, [], None)
>>> Field(
...     name = "abstract",
...     type = "string",
...     indexing = ["attribute"],
...     attribute=["fast-search", "fast-access"]
... )
Field('abstract', 'string', ['attribute'], None, ['fast-search', 'fast-access'], None, None, None, None, None, True, None, None, None, [], None)
>>> Field(name="tensor_field",
...     type="tensor<float>(x[128])",
...     indexing=["attribute"],
...     ann=HNSW(
...         distance_metric="euclidean",
...         max_links_per_node=16,
...         neighbors_to_explore_at_insert=200,
...     ),
... )
Field('tensor_field', 'tensor<float>(x[128])', ['attribute'], None, None, HNSW('euclidean', 16, 200), None, None, None, None, True, None, None, None, [], None)
>>> Field(
...     name = "abstract",
...     type = "string",
...     match = ["exact", ("exact-terminator", '"@%"',)],
... )
Field('abstract', 'string', None, None, None, None, ['exact', ('exact-terminator', '"@%"')], None, None, None, True, None, None, None, [], None)
>>> Field(
...     name = "abstract",
...     type = "string",
...     weight = 200,
... )
Field('abstract', 'string', None, None, None, None, None, 200, None, None, True, None, None, None, [], None)
>>> Field(
...     name = "abstract",
...     type = "string",
...     bolding = True,
... )
Field('abstract', 'string', None, None, None, None, None, None, True, None, True, None, None, None, [], None)
>>> Field(
...     name = "abstract",
...     type = "string",
...     summary = Summary(None, None, ["dynamic", ["bolding", "on"]]),
... )
Field('abstract', 'string', None, None, None, None, None, None, None, Summary(None, None, ['dynamic', ['bolding', 'on']]), True, None, None, None, [], None)
>>> Field(
...     name = "abstract",
...     type = "string",
...     stemming = "shortest",
... )
Field('abstract', 'string', None, None, None, None, None, None, None, None, True, 'shortest', None, None, [], None)
>>> Field(
...     name = "abstract",
...     type = "string",
...     rank = "filter",
... )
Field('abstract', 'string', None, None, None, None, None, None, None, None, True, None, 'filter', None, [], None)
>>> Field(
...     name = "abstract",
...     type = "string",
...     query_command = ['"exact %%"'],
... )
Field('abstract', 'string', None, None, None, None, None, None, None, None, True, None, None, ['"exact %%"'], [], None)
>>> Field(
...     name = "abstract",
...     type = "string",
...     struct_fields = [
...         StructField(
...             name = "first_name",
...             indexing = ["attribute"],
...             attribute = ["fast-search"],
...         ),
...     ],
... )
Field('abstract', 'string', None, None, None, None, None, None, None, None, True, None, None, None, [StructField('first_name', ['attribute'], ['fast-search'], None, None, None)], None)
>>> Field(
...     name = "artist",
...     type = "string",
...     alias = ["artist_name"],
... )
Field('artist', 'string', None, None, None, None, None, None, None, None, True, None, None, None, [], ['artist_name'])
add_struct_fields(*struct_fields: StructField) None

Add StructField’s to the Field.

Parameters:

struct_fields – struct-fields to be added

FieldSet

class vespa.package.FieldSet(name: str, fields: List[str])
__init__(name: str, fields: List[str]) None

Create a Vespa field set.

A fieldset groups fields together for searching. Check the Vespa documentation for more detailed information about field sets.

Parameters:
  • name – Name of the fieldset

  • fields – Field names to be included in the fieldset.

>>> FieldSet(name="default", fields=["title", "body"])
FieldSet('default', ['title', 'body'])

FirstPhaseRanking

class vespa.package.FirstPhaseRanking(expression: str, keep_rank_count: int | None = None, rank_score_drop_limit: float | None = None)
__init__(expression: str, keep_rank_count: int | None = None, rank_score_drop_limit: float | None = None) None

Create a Vespa first phase ranking configuration.

This is the initial ranking performed on all matching documents. Check the Vespa documentation for more detailed information about first phase ranking configuration.

Parameters:
  • expression – Specify the ranking expression to be used for first phase of ranking. Check also the Vespa documentation for ranking expression.

  • keep_rank_count – How many documents to keep the first phase top rank values for. Default value is 10000.

  • rank_score_drop_limit – Drop all hits with a first phase rank score less than or equal to this floating point number.

>>> FirstPhaseRanking("myFeature * 10")
FirstPhaseRanking('myFeature * 10', None, None)
>>> FirstPhaseRanking(expression="myFeature * 10", keep_rank_count=50, rank_score_drop_limit=10)
FirstPhaseRanking('myFeature * 10', 50, 10)

Function

class vespa.package.Function(name: str, expression: str, args: List[str] | None = None)
__init__(name: str, expression: str, args: List[str] | None = None) None

Create a Vespa rank function.

Define a named function that can be referenced as a part of the ranking expression, or (if having no arguments) as a feature. Check the Vespa documentation for more detailed information about rank functions.

Parameters:
  • name – Name of the function.

  • expression – String representing a Vespa expression.

  • args – Optional. List of arguments to be used in the function expression.

>>> Function(
...     name="myfeature",
...     expression="fieldMatch(bar) + freshness(foo)",
...     args=["foo", "bar"]
... )
Function('myfeature', 'fieldMatch(bar) + freshness(foo)', ['foo', 'bar'])

It is possible to define functions with multi-line expressions:

>>> Function(
...     name="token_type_ids",
...     expression="tensor<float>(d0[1],d1[128])(\n"
...                "    if (d1 < question_length,\n"
...                "        0,\n"
...                "    if (d1 < question_length + doc_length,\n"
...                "        1,\n"
...                "        TOKEN_NONE\n"
...                "    )))",
... )
Function('token_type_ids', 'tensor<float>(d0[1],d1[128])(\n    if (d1 < question_length,\n        0,\n    if (d1 < question_length + doc_length,\n        1,\n        TOKEN_NONE\n    )))', None)

HNSW

class vespa.package.HNSW(distance_metric: Literal['euclidean', 'angular', 'dotproduct', 'prenormalized-angular', 'hamming', 'geodegrees'] = 'euclidean', max_links_per_node=16, neighbors_to_explore_at_insert=200)
__init__(distance_metric: Literal['euclidean', 'angular', 'dotproduct', 'prenormalized-angular', 'hamming', 'geodegrees'] = 'euclidean', max_links_per_node=16, neighbors_to_explore_at_insert=200)

Configure Vespa HNSW indexes Check the Vespa documentation

Parameters:
  • distance_metric – Distance metric to use when computing distance between vectors. Default is ‘euclidean’.

  • max_links_per_node – Specifies how many links per HNSW node to select when building the graph. Default is 16.

  • neighbors_to_explore_at_insert – Specifies how many neighbors to explore when inserting a document in the HNSW graph. Default is 200.

ImportedField

class vespa.package.ImportedField(name: str, reference_field: str, field_to_import: str)
__init__(name: str, reference_field: str, field_to_import: str) None

Imported field from a reference document.

Useful to implement parent/child relationships.

Parameters:
  • name – Field name.

  • reference_field – field of type reference that points to the document that contains the field to be imported.

  • field_to_import – Field name to be imported, as defined in the reference document.

>>> ImportedField(
...     name="global_category_ctrs",
...     reference_field="category_ctr_ref",
...     field_to_import="ctrs",
... )
ImportedField('global_category_ctrs', 'category_ctr_ref', 'ctrs')

OnnxModel

class vespa.package.OnnxModel(model_name: str, model_file_path: str, inputs: Dict[str, str], outputs: Dict[str, str])
__init__(model_name: str, model_file_path: str, inputs: Dict[str, str], outputs: Dict[str, str]) None

Create a Vespa ONNX model config.

Vespa has support for advanced ranking models through it’s tensor API. If you have your model in the ONNX format, Vespa can import the models and use them directly. Check the Vespa documentation for more detailed information about field sets.

Parameters:
  • model_name – Unique model name to use as id when referencing the model.

  • model_file_path – ONNX model file path.

  • inputs – Dict mapping the ONNX input names as specified in the ONNX file to valid Vespa inputs, which can be a document field (attribute(field_name)), a query parameter (query(query_param)), a constant (constant(name)) and a user-defined function (function_name).

  • outputs – Dict mapping the ONNX output names as specified in the ONNX file to the name used in Vespa to specify the output. If this is omitted, the first output in the ONNX file will be used.

>>> OnnxModel(
...     model_name="bert",
...     model_file_path="bert.onnx",
...     inputs={
...         "input_ids": "input_ids",
...         "token_type_ids": "token_type_ids",
...         "attention_mask": "attention_mask",
...     },
...     outputs={"logits": "logits"},
... )
OnnxModel('bert', 'bert.onnx', {'input_ids': 'input_ids', 'token_type_ids': 'token_type_ids', 'attention_mask': 'attention_mask'}, {'logits': 'logits'})

QueryProfile

class vespa.package.QueryProfile(fields: List[QueryField] | None = None)
__init__(fields: List[QueryField] | None = None) None

Create a Vespa Query Profile.

Check the Vespa documentation for more detailed information about query profiles.

A QueryProfile is a named collection of query request parameters given in the configuration. The query request can specify a query profile whose parameters will be used as parameters of that request. The query profiles may optionally be type checked. Type checking is turned on by referencing a QueryProfileType from the query profile.

Parameters:

fields – A list of QueryField.

>>> QueryProfile(fields=[QueryField(name="maxHits", value=1000)])
QueryProfile([QueryField('maxHits', 1000)])
add_fields(*fields: QueryField) None

Add QueryField’s to the Query Profile.

Parameters:

fields – fields to be added

>>> query_profile = QueryProfile()
>>> query_profile.add_fields(QueryField(name="maxHits", value=1000))

QueryField

class vespa.package.QueryField(name: str, value: str | int | float)
__init__(name: str, value: str | int | float) None

Create a field to be included in a QueryProfile.

Parameters:
  • name – Field name.

  • value – Field value.

>>> QueryField(name="maxHits", value=1000)
QueryField('maxHits', 1000)

QueryProfileType

class vespa.package.QueryProfileType(fields: List[QueryTypeField] | None = None)
__init__(fields: List[QueryTypeField] | None = None) None

Create a Vespa Query Profile Type.

Check the Vespa documentation for more detailed information about query profile types.

An ApplicationPackage instance comes with a default QueryProfile named default that is associated with a QueryProfileType named root, meaning that you usually do not need to create those yourself, only add fields to them when required.

Parameters:

fields – A list of QueryTypeField.

>>> QueryProfileType(
...     fields = [
...         QueryTypeField(
...             name="ranking.features.query(tensor_bert)",
...             type="tensor<float>(x[768])"
...         )
...     ]
... )
QueryProfileType([QueryTypeField('ranking.features.query(tensor_bert)', 'tensor<float>(x[768])')])
add_fields(*fields: QueryTypeField) None

Add QueryTypeField’s to the Query Profile Type.

Parameters:

fields – fields to be added

>>> query_profile_type = QueryProfileType()
>>> query_profile_type.add_fields(
...     QueryTypeField(
...         name="age",
...         type="integer"
...     ),
...     QueryTypeField(
...         name="profession",
...         type="string"
...     )
... )

QueryTypeField

class vespa.package.QueryTypeField(name: str, type: str)
__init__(name: str, type: str) None

Create a field to be included in a QueryProfileType.

Parameters:
  • name – Field name.

  • type – Field type.

>>> QueryTypeField(
...     name="ranking.features.query(title_bert)",
...     type="tensor<float>(x[768])"
... )
QueryTypeField('ranking.features.query(title_bert)', 'tensor<float>(x[768])')

RankProfile

class vespa.package.RankProfile(name: str, first_phase: str | ~vespa.package.FirstPhaseRanking, inherits: str | None = None, constants: ~typing.Dict | None = None, functions: ~typing.List[~vespa.package.Function] | None = None, summary_features: ~typing.List | None = None, match_features: ~typing.List | None = None, second_phase: ~vespa.package.SecondPhaseRanking | None = None, global_phase: ~vespa.package.GlobalPhaseRanking | None = None, **kwargs: ~typing_extensions.)
__init__(name: str, first_phase: str | ~vespa.package.FirstPhaseRanking, inherits: str | None = None, constants: ~typing.Dict | None = None, functions: ~typing.List[~vespa.package.Function] | None = None, summary_features: ~typing.List | None = None, match_features: ~typing.List | None = None, second_phase: ~vespa.package.SecondPhaseRanking | None = None, global_phase: ~vespa.package.GlobalPhaseRanking | None = None, **kwargs: ~typing_extensions.) None

Create a Vespa rank profile.

Rank profiles are used to specify an alternative ranking of the same data for different purposes, and to experiment with new rank settings. Check the Vespa documentation for more detailed information about rank profiles.

Parameters:
  • name – Rank profile name.

  • first_phase – The config specifying the first phase of ranking. More info about first phase ranking.

  • inherits – The inherits attribute is optional. If defined, it contains the name of one other rank profile in the same schema. Values not defined in this rank profile will then be inherited.

  • constants – Dict of constants available in ranking expressions, resolved and optimized at configuration time. More info about constants.

  • functions – Optional list of Function representing rank functions to be included in the rank profile.

  • summary_features – List of rank features to be included with each hit. More info about summary features.

  • match_features – List of rank features to be included with each hit. More info about match features.

  • second_phase – Optional config specifying the second phase of ranking. See SecondPhaseRanking.

  • global_phase – Optional config specifying the global phase of ranking. See GlobalPhaseRanking.

Key weight:

A list of tuples containing the field and their weight

Key rank_type:

A list of tuples containing a field and the rank-type-name. More info about rank-type.

Key rank_properties:

A list of tuples containing a field and its configuration. More info about rank-properties.

>>> RankProfile(name = "default", first_phase = "nativeRank(title, body)")
RankProfile('default', 'nativeRank(title, body)', None, None, None, None, None, None, None, None, None, None, None)
>>> RankProfile(name = "new", first_phase = "BM25(title)", inherits = "default")
RankProfile('new', 'BM25(title)', 'default', None, None, None, None, None, None, None, None, None, None)
>>> RankProfile(
...     name = "new",
...     first_phase = "BM25(title)",
...     inherits = "default",
...     constants={"TOKEN_NONE": 0, "TOKEN_CLS": 101, "TOKEN_SEP": 102},
...     summary_features=["BM25(title)"]
... )
RankProfile('new', 'BM25(title)', 'default', {'TOKEN_NONE': 0, 'TOKEN_CLS': 101, 'TOKEN_SEP': 102}, None, ['BM25(title)'], None, None, None, None, None, None, None)
>>> RankProfile(
...     name="bert",
...     first_phase="bm25(title) + bm25(body)",
...     second_phase=SecondPhaseRanking(expression="1.25 * bm25(title) + 3.75 * bm25(body)", rerank_count=10),
...     inherits="default",
...     constants={"TOKEN_NONE": 0, "TOKEN_CLS": 101, "TOKEN_SEP": 102},
...     functions=[
...         Function(
...             name="question_length",
...             expression="sum(map(query(query_token_ids), f(a)(a > 0)))"
...         ),
...         Function(
...             name="doc_length",
...             expression="sum(map(attribute(doc_token_ids), f(a)(a > 0)))"
...         )
...     ],
...     summary_features=["question_length", "doc_length"]
... )
RankProfile('bert', 'bm25(title) + bm25(body)', 'default', {'TOKEN_NONE': 0, 'TOKEN_CLS': 101, 'TOKEN_SEP': 102}, [Function('question_length', 'sum(map(query(query_token_ids), f(a)(a > 0)))', None), Function('doc_length', 'sum(map(attribute(doc_token_ids), f(a)(a > 0)))', None)], ['question_length', 'doc_length'], None, SecondPhaseRanking('1.25 * bm25(title) + 3.75 * bm25(body)', 10), None, None, None, None, None)
>>> RankProfile(
...     name = "default",
...     first_phase = "nativeRank(title, body)",
...     weight = [("title", 200), ("body", 100)]
... )
RankProfile('default', 'nativeRank(title, body)', None, None, None, None, None, None, None, [('title', 200), ('body', 100)], None, None, None)
>>> RankProfile(
...     name = "default",
...     first_phase = "nativeRank(title, body)",
...     rank_type = [("body", "about")]
... )
RankProfile('default', 'nativeRank(title, body)', None, None, None, None, None, None, None, None, [('body', 'about')], None, None)
>>> RankProfile(
...     name = "default",
...     first_phase = "nativeRank(title, body)",
...     rank_properties = [("fieldMatch(title).maxAlternativeSegmentations", "10")]
... )
RankProfile('default', 'nativeRank(title, body)', None, None, None, None, None, None, None, None, None, [('fieldMatch(title).maxAlternativeSegmentations', '10')], None)
>>> RankProfile(
...    name = "default",
...    first_phase = FirstPhaseRanking(expression="nativeRank(title, body)", keep_rank_count=50)
... )
RankProfile('default', FirstPhaseRanking('nativeRank(title, body)', 50, None), None, None, None, None, None, None, None, None, None, None, None)

Schema

class vespa.package.Schema(name: str, document: ~vespa.package.Document, fieldsets: ~typing.List[~vespa.package.FieldSet] | None = None, rank_profiles: ~typing.List[~vespa.package.RankProfile] | None = None, models: ~typing.List[~vespa.package.OnnxModel] | None = None, global_document: bool = False, imported_fields: ~typing.List[~vespa.package.ImportedField] | None = None, document_summaries: ~typing.List[~vespa.package.DocumentSummary] | None = None, mode: str | None = 'index', inherits: str | None = None, **kwargs: ~typing_extensions.)
__init__(name: str, document: ~vespa.package.Document, fieldsets: ~typing.List[~vespa.package.FieldSet] | None = None, rank_profiles: ~typing.List[~vespa.package.RankProfile] | None = None, models: ~typing.List[~vespa.package.OnnxModel] | None = None, global_document: bool = False, imported_fields: ~typing.List[~vespa.package.ImportedField] | None = None, document_summaries: ~typing.List[~vespa.package.DocumentSummary] | None = None, mode: str | None = 'index', inherits: str | None = None, **kwargs: ~typing_extensions.) None

Create a Vespa Schema.

Check the Vespa documentation for more detailed information about schemas.

Parameters:
  • name – Schema name.

  • document – Vespa Document associated with the Schema.

  • fieldsets – A list of FieldSet associated with the Schema.

  • rank_profiles – A list of RankProfile associated with the Schema.

  • models – A list of OnnxModel associated with the Schema.

  • global_document – Set to True to copy the documents to all content nodes. Default to False.

  • imported_fields – A list of ImportedField defining fields from global documents to be imported.

  • document_summaries – A list of DocumentSummary associated with the schema.

  • mode – Schema mode. Defaults to ‘index’. Other options are ‘store-only’ and ‘streaming’.

  • inherits – Schema to inherit from.

Key stemming:

The default stemming setting. Defaults to ‘best’.

To create a Schema:

>>> Schema(name="schema_name", document=Document())
Schema('schema_name', Document(None, None, None), None, None, [], False, None, [], None)
add_document_summary(document_summary: DocumentSummary) None

Add a DocumentSummary to the Schema.

Parameters:

document_summary – document summary to be added.

add_field_set(field_set: FieldSet) None

Add a FieldSet to the Schema.

Parameters:

field_set – field sets to be added.

add_fields(*fields: Field) None

Add Field to the Schema’s Document.

Parameters:

fields – fields to be added.

add_imported_field(imported_field: ImportedField) None

Add a ImportedField to the Schema.

Parameters:

imported_field – imported field to be added.

add_model(model: OnnxModel) None

Add a OnnxModel to the Schema.

Parameters:

model – model to be added.

Returns:

None.

add_rank_profile(rank_profile: RankProfile) None

Add a RankProfile to the Schema.

Parameters:

rank_profile – rank profile to be added.

Returns:

None.

SecondPhaseRanking

class vespa.package.SecondPhaseRanking(expression: str, rerank_count: int = 100)
__init__(expression: str, rerank_count: int = 100) None

Create a Vespa second phase ranking configuration.

This is the optional reranking performed on the best hits from the first phase. Check the Vespa documentation for more detailed information about second phase ranking configuration.

Parameters:
  • expression – Specify the ranking expression to be used for second phase of ranking. Check also the Vespa documentation for ranking expression.

  • rerank_count – Specifies the number of hits to be reranked in the second phase. Default value is 100.

>>> SecondPhaseRanking(expression="1.25 * bm25(title) + 3.75 * bm25(body)", rerank_count=10)
SecondPhaseRanking('1.25 * bm25(title) + 3.75 * bm25(body)', 10)

Struct

class vespa.package.Struct(name: str, fields: List[Field] | None = None)
__init__(name: str, fields: List[Field] | None = None)

Create a Vespa struct. A struct defines a composite type. Check the Vespa documentation for more detailed information about structs.

Parameters:
  • name – Name of the struct

  • fields – Field names to be included in the fieldset

>>> Struct("person")
Struct('person', None)
>>> Struct(
...     "person",
...     [
...         Field("first_name", "string"),
...         Field("last_name", "string"),
...     ],
... )
Struct('person', [Field('first_name', 'string', None, None, None, None, None, None, None, None, True, None, None, None, [], None), Field('last_name', 'string', None, None, None, None, None, None, None, None, True, None, None, None, [], None)])

StructField

class vespa.package.StructField(name: str, **kwargs: ~typing_extensions.)
__init__(name: str, **kwargs: ~typing_extensions.) None

Create a Vespa struct-field. Check the Vespa documentation for more detailed information about struct-fields.

Parameters:

name – Struct-field name.

Key indexing:

Configures how to process data of a struct-field during indexing.

Key attribute:

Specifies a property of an index structure attribute.

Key match:

Set properties that decide how the matching method for this field operate.

Key query_command:

Add configuration for query-command of the field.

Key summary:

Add configuration for summary of the field.

>>> StructField(
...     name = "first_name",
... )
StructField('first_name', None, None, None, None, None)
>>> StructField(
...     name = "first_name",
...     indexing = ["attribute"],
...     attribute = ["fast-search"],
... )
StructField('first_name', ['attribute'], ['fast-search'], None, None, None)
>>> StructField(
...     name = "last_name",
...     match = ["exact", ("exact-terminator", '"@%"')],
...     query_command = ['"exact %%"'],
...     summary = Summary(None, None, fields=["dynamic", ("bolding", "on")])
... )
StructField('last_name', None, None, ['exact', ('exact-terminator', '"@%"')], ['"exact %%"'], Summary(None, None, ['dynamic', ('bolding', 'on')]))

Summary

class vespa.package.Summary(name: str | None = None, type: str | None = None, fields: List[str | Tuple[str, List[str] | str]] | None = None)
__init__(name: str | None = None, type: str | None = None, fields: List[str | Tuple[str, List[str] | str]] | None = None) None

Configures a summary Field.

Parameters:
  • name – Name of the summary field, can be None if used inside a Field, which then uses the name of the Field.

  • type – Type of the summary field, can be None if used inside a Field, which then uses the type of the Field.

  • fields – List of properties used to configure the summary, can be single properties (like “summary: dynamic”, common in Field), or composite values (like “source: another_field”)

>>> Summary(None, None, ["dynamic"])
Summary(None, None, ['dynamic'])
>>> Summary(
...     "title",
...     "string",
...     [("source", "title")]
... )
Summary('title', 'string', [('source', 'title')])
>>> Summary(
...     "title",
...     "string",
...     [("source", ["title", "abstract"])]
... )
Summary('title', 'string', [('source', ['title', 'abstract'])])
>>> Summary(
...     name = "artist",
...     type = "string",
... )
Summary('artist', 'string', None)
property as_lines: List[str]

Returns the object as a List of str, each str representing a line of configuration that can be used during schema generation as such:

` {% for line in field.summary.as_lines %} {{ line }} {% endfor %} `

>>> Summary(None, None, ["dynamic"]).as_lines
['summary: dynamic']
>>> Summary(
...     "artist",
...     "string",
... ).as_lines
['summary artist type string {}']
>>> Summary(
...     "artist",
...     "string",
...     [("bolding", "on"), ("sources", "artist")],
... ).as_lines
['summary artist type string {', '    bolding: on', '    sources: artist', '}']

Validation

class vespa.package.Validation(validation_id: ValidationID | str, until: str, comment: str | None = None)
__init__(validation_id: ValidationID | str, until: str, comment: str | None = None)

Represents a validation to be overridden on application.

Check the Vespa documentation for more detailed information about validations.

Parameters:
  • validation_id – ID of the validation.

  • until – The last day this change is allowed, as a ISO-8601-format date in UTC, e.g. 2016-01-30. Dates may at most be 30 days in the future, but should be as close to now as possible for safety, while allowing time for review and propagation to all deployed zones. allow-tags with dates in the past are ignored.

  • comment – Optional text explaining the reason for the change to humans.