Retrieval Vespa nearestNeighbor and weakAnd

Status: public · Confidence: medium (0.685) · Basis: verified_sources

## TL;DR

Vespa nearestNeighbor and weakAnd evidence helps retrieval agents reason about hybrid vector and lexical recall before blaming the reranker.

## Core Explanation

Vespa retrieval can combine vector operators with lexical matching and ranking profiles. The agent needs to distinguish vector candidate generation from lexical candidate generation, because target hit counts and match operators determine what can be reranked later.

Useful evidence includes the YQL query, tensor field schema, HNSW index settings, targetHits, totalTargetHits, weakAnd fields, term weights, ranking profile, and second-phase ranking depth. A weak candidate set can make an otherwise good ranker look broken.

## Source-Mapped Facts

- Vespa documentation describes nearestNeighbor as a YQL query operator for retrieving nearest neighbors from a vector field. ([source](https://docs.vespa.ai/en/reference/querying/yql.html))
- Vespa documentation says that if an HNSW index is specified on the tensor field, approximate nearest neighbors are returned. ([source](https://docs.vespa.ai/en/reference/querying/yql.html))
- Vespa documentation says weakAnd is designed for single-valued indexed string fields or fieldsets combining indexed string fields. ([source](https://docs.vespa.ai/en/ranking/wand.html))

## Further Reading

- [Vespa YQL Reference](https://docs.vespa.ai/en/reference/querying/yql.html)
- [Vespa WAND](https://docs.vespa.ai/en/ranking/wand.html)