vespaclient-java module.
Overview
The Vespa Java client libraries provide command-line tools and APIs for:- vespa-feeder: Feed documents from files
- vespa-get: Retrieve documents by ID
- vespa-visit: Visit and export documents
- vespa-stat: Show content cluster statistics
Installation
Add the dependency to your Maven project:pom.xml
build.gradle
vespa-feeder
Thevespa-feeder tool feeds documents from XML or JSON files to Vespa.
Basic Usage
XML Format
Documents in XML format:JSON Format
Documents in JSON format (same as Document API):Options
vespa-feeder Options
vespa-feeder Options
| Option | Description | Default |
|---|---|---|
--abortondataerror <bool> | Abort on data errors | true |
--abortonsenderror <bool> | Abort on send errors | true |
--file <file> | Input file to read | stdin |
--maxpending <num> | Max pending operations | 1000 |
--maxpendingsize <bytes> | Max pending operation size | 1MB |
--route <route> | Route to use | default |
--timeout <seconds> | Timeout for operations | 180 |
--trace <level> | Trace level (0-9) | 0 |
vespa-get
Retrieve documents by their document ID.Basic Usage
Output Format
By default, outputs JSON:Options
vespa-get Options
vespa-get Options
| Option | Description |
|---|---|
--fieldset <fields> | Fields to retrieve |
--printids | Print document IDs |
--jsonoutput | Output in JSON format |
--xmloutput | Output in XML format |
--cluster <name> | Content cluster name |
--route <route> | Route to use |
--timeout <seconds> | Operation timeout |
vespa-visit
Visit (iterate over) documents in a content cluster.Basic Usage
Selection Expressions
Filter documents during visit:Export and Backup
Usevespa-visit for backups:
Options
vespa-visit Options
vespa-visit Options
| Option | Description | Default |
|---|---|---|
--datahandler <type> | Document type to visit | all |
--selection <expr> | Document selection | none |
--from <timestamp> | Visit from timestamp | 0 |
--to <timestamp> | Visit to timestamp | now |
--fieldset <fields> | Fields to retrieve | all |
--cluster <name> | Content cluster | default |
--maxpending <num> | Max pending operations | 1 |
--maxbucketstovisit <num> | Max buckets | unlimited |
--bucketstovisit <list> | Specific buckets | all |
--statistics | Show statistics | false |
vespa-stat
Show statistics about content clusters.Basic Usage
Output Example
Using in Java Applications
Document Operations
While dedicated feed clients are recommended for production use, you can use the HTTP client directly:For production applications with high throughput requirements, use the Vespa Feed Client which provides optimized performance, automatic retries, and better error handling.
Error Handling
Common Errors
Connection Refused
Connection Refused
The Vespa endpoint is not reachable. Check:
- Is Vespa running?
- Is the correct host/port specified?
- Are firewall rules blocking access?
Document Type Not Found
Document Type Not Found
The document type doesn’t exist in the schema:
- Verify schema deployment
- Check document type name spelling
- Ensure application is deployed
Timeout Errors
Timeout Errors
Operations are taking too long:
- Increase timeout:
--timeout 300 - Check cluster health:
vespa-stat - Reduce batch size
Performance Considerations
When to Use Each Tool
| Tool | Best For | Throughput |
|---|---|---|
| vespa-feeder | Small datasets, testing | Low |
| vespa-get | Individual document retrieval | N/A |
| vespa-visit | Backups, exports, iteration | Medium |
| Feed Client | Production bulk feeding | High |
| CLI feed | Command-line bulk feeding | High |
Next Steps
Feed Client
High-performance Java feed client
Vespa CLI
Modern command-line interface
Document API
Document operations reference
Data Operations
Document API operations guide