Question 270
A design review raises this concern: A team uses Euclidean nearest-neighbor operator ordering despite defining acceptance based on cosine distance between semantic embeddings. Which technical principle should guide the solution?
Explanation
Correct Answer
pgvector operators and their index operator classes must match the intended similarity metric. The scenario specifically states: A team uses Euclidean nearest-neighbor operator ordering despite defining acceptance based on cosine distance between semantic embeddings. pgvector operators and their index operator classes must match the intended similarity metric. The stated requirement hinges on the exact service behavior, not a different component. The decisive evidence to inspect is Inspect ORDER BY operator, vector data normalization and index operator class. The important remaining qualification is: Cosine and Euclidean similarity rankings are not generally interchangeable without assumptions.
Incorrect Answers
PostgreSQL GIN indexes can accelerate supported JSONB containment and key operators. That addresses a different mechanism; this question turns on pgvector operators and their index operator classes must match.
SQL can combine pgvector distance ordering with structured predicates in one query. In the present case the governing issue is Pgvector operators and their index operator classes must match, which this does not resolve.
IVFFlat index quality depends on representative existing data and list/probe configuration. It does not verify the requested outcome; here the decisive check concerns pgvector operators and their index operator classes must match.