Implementation:Vespa engine Vespa ScriptManager GetScript
| Knowledge Sources | |
|---|---|
| Domains | Document_Processing, Indexing |
| Last Updated | 2026-02-09 00:00 GMT |
Overview
Concrete tool for resolving document types to their corresponding indexing scripts, provided by Vespa's document processing framework.
Description
ScriptManager maintains a registry of compiled indexing scripts organized by document type and field name. It provides lookup methods to retrieve the appropriate DocumentScript for a given DocumentType.
The class uses a two-level map structure: the outer map is keyed by document type name, and the inner map is keyed by field name. A special constant FULL (value "[all]") is used as the field key for full-document scripts that process all fields at once.
Two overloaded getScript methods are provided:
- A single-argument version that retrieves the full-document script by defaulting the field name to
FULL. - A two-argument version that retrieves a field-specific script for partial update processing.
When no script exists for the requested document type, both methods return null, indicating that the document should pass through without indexing transformation.
Usage
This implementation is used internally by IndexingProcessor to look up the correct indexing script before processing each document operation. The single-argument form is used for document put operations, while the two-argument form is used for document update operations that target specific fields.
Use this implementation when:
- You need to understand how Vespa resolves indexing scripts for document types.
- You are debugging script resolution failures where a document type is not being processed.
- You want to inspect which scripts are registered for a given document type.
Code Reference
Source Location
- Repository: Vespa
- File:
docprocs/src/main/java/com/yahoo/docprocs/indexing/ScriptManager.java - Lines: 58-60
Signature
class ScriptManager {
static final String FULL = "[all]";
DocumentScript getScript(DocumentType inputType);
DocumentScript getScript(DocumentType inputType, String inputFieldName);
}
Import
import com.yahoo.docprocs.indexing.ScriptManager;
Full Method Body
DocumentScript getScript(DocumentType inputType) {
return getScript(inputType, FULL);
}
DocumentScript getScript(DocumentType inputType, String inputFieldName) {
Map<String, DocumentScript> fieldScripts = getScripts(inputType);
if (fieldScripts == null) return null;
return fieldScripts.get(inputFieldName);
}
I/O Contract
Inputs
| Name | Type | Required | Description |
|---|---|---|---|
| inputType | DocumentType |
Yes | The document type for which to look up the indexing script. Used as the key in the outer map of the script registry. |
| inputFieldName | String |
No | The specific field name for per-field script lookup. Defaults to "[all]" when using the single-argument overload, which retrieves the full-document script.
|
Outputs
| Name | Type | Description |
|---|---|---|
| return value | DocumentScript |
The compiled indexing script for the given document type and field, or null if no script is registered for the specified type.
|
Key Fields
| Field | Type | Description |
|---|---|---|
| documentFieldScripts | Map<String, Map<String, DocumentScript>> |
Two-level map from document type name to field name to compiled indexing script. The outer key is the document type name, the inner key is the field name (or "[all]" for the full-document script).
|
Usage Examples
// Retrieving the full-document script for a document type
DocumentType articleType = documentTypeManager.getDocumentType("article");
DocumentScript fullScript = scriptManager.getScript(articleType);
if (fullScript != null) {
// Execute the full-document indexing script
Document indexed = fullScript.execute(fieldValuesFactory, document, false, deadline);
} else {
// No indexing script for this type; pass through unchanged
}
// Retrieving a field-specific script for a partial update
DocumentScript titleScript = scriptManager.getScript(articleType, "title");
if (titleScript != null) {
// Process only the title field
}