This page explains the concepts that make up a Vespa application: the application package, schemas, fields, ranking profiles, and query profiles. To learn how to create and configure these, see Manage schema.

Application package

Application package

A Vespa application package is a set of configuration files that tell the cluster how to store and rank documents:

<app-package>/
├── schemas/
│   └── <document_type>.sd        # Schema definitions
└── search/
    └── query-profiles/
        ├── <profile_name>.xml    # Query profiles
        └── types/root.xml        # Query profile types

You never write these files by hand. They are built in memory from your migrations and uploaded to the Vespa cluster. You can inspect them with mistral-vespa generate (see CLI reference).

Migrations: Build the application package

Migrations: Build the application package

Migrations are Python files that serve as the source of truth for your application package. Instead of manually writing schema definitions and configuration files, you define schemas, fields, and ranking through Python migrations.

How it works:

  1. Create migration files in vespa_app/migrations/ that describe your schemas and configuration
  2. Run mistral-vespa migrate to execute all migrations in order
  3. The migration system builds the complete application package in memory
  4. The package is deployed to your Vespa cluster

Properties of migrations:

  • Append-only: add new files for changes, never edit existing ones
  • Ordered: sorted by timestamp prefix, executed sequentially on every deploy
  • Version controlled: the only thing you commit to your repository
  • Idempotent: safe to re-run without side effects

This approach lets you version and evolve your schema like any other source code, with full history and the ability to review changes.

Schemas

Schemas

A schema defines a document type. It declares the fields a document contains, how those fields are indexed, and how results are ranked. Each schema produces a .sd file and a query profile in the application package.

An application can contain multiple schemas, each representing a different document type (e.g., articles, comments). Names must be unique.

Search mode

Each schema operates in one of two modes:

ModeDescription
SearchMode.INDEXTraditional indexed search: BM25, ANN/HNSW, two-phase ranking
SearchMode.STREAMINGStreaming search: exact nearest neighbor, attribute filtering, single-phase ranking

Indexing mode

Each schema also declares an indexing mode that controls how documents are laid out in Vespa. It is required on every schema, so the layout is always explicit.

ModeDescription
IndexingMode.DOCUMENT_PER_CHUNKRecommended. One Vespa document per chunk, each individually addressable by its deterministic id.
IndexingMode.SINGLE_DOCUMENTLegacy: one Vespa document per source, with chunks packed as arrays. Deprecated. Removed before 1.0.0.

With DOCUMENT_PER_CHUNK, create_schema() injects the standard chunk fields (content, embedding, identity, metadata) automatically. See the Document model for how chunks are identified, Manage Schema for how to set the mode, and the Migration helpers reference for the full create_schema() signature.

Fields

Fields

Fields define what data a document holds and how that data is used for indexing and ranking. The plugin provides these field types:

Field TypePurposeVespa IndexingGenerated Ranking Functions
EmbeddingFieldVector embeddings for semantic searchattribute + HNSW indexDistance, cosine similarity
TextFieldText for keyword/BM25 searchindex + summaryBM25, field match
StringFieldStored metadata, not searchableattribute + summaryNone
TimestampFieldTime-based ranking (type: long/int)attribute + summaryFreshness, recency boost
CountFieldNumeric ranking (type: int)attribute + summaryNormalization, boost
IntFieldStored integer, not rankedattribute + summaryNone
BoolFieldStored boolean, not rankedattribute + summaryNone
LanguageFieldPer-document language tag (RFC 3066)indexNone

Fields can be single-valued or multi-dimensional (arrays). Set multi_dimensional=True for an array field, for example a list of tags or section embeddings. See the Migration helpers reference for every field type's constructor signature.

Default fieldset

The plugin generates a default fieldset containing all TextField fields. This fieldset defines which fields are searched when using userQuery() in YQL. Other field types are excluded.

Ranking profiles

Ranking profiles

The plugin generates four ranking profiles per schema:

ProfilePurpose
rootBase profile containing all auto-generated and custom functions
match-onlyUsed to evaluate the retrieval phase, no ranking applied
weighted-rank1Phase 1: linear combination of phase-1 functions with query-time weights
weighted-rank2Phase 1 + 2: adds phase-2 functions on top of weighted-rank1

Phased ranking

Vespa ranks documents in phases to balance speed and quality:

  1. First phase: applied to all matching documents. Must be fast. Uses functions like BM25, embedding distance, freshness.
  2. Second phase: re-ranks the top k documents from phase 1. Can use more expensive functions like field match, logarithmic scoring, or ML models.
  3. Global phase (optional): runs on the merged result set in the container node.

The plugin maps each auto-generated function to the appropriate phase based on field type.

Weighted profiles

The weighted-rank1 and weighted-rank2 profiles let you tune ranking at query time by adjusting function weights without modifying the schema.

Phase 1: bm25_title_weight * bm25_title +
         content_embedding_distance_weight * content_embedding_distance +
         freshness_created_at_weight * freshness_created_at

Phase 2: firstPhase +
         match_title_weight * match_title +
         log_freshness_created_at_weight * log_freshness_created_at

All weights start at 0. Set one or more to a non-zero value to activate ranking.

Query profiles

Query profiles

The plugin generates one query profile per schema (named via default_query_profile_name, defaults to the schema name). It includes:

  • A YQL query for hybrid search (if embeddings are present) or keyword search
  • The weighted-rank2 ranking profile as default
  • Query type fields for function weights

For more, see Manage ranking and the Vespa documentation on query profiles.

See also

See also