code · Nov 8, 2026

Qdrant score violates a Postgres CHECK

Why can cosine similarity from Qdrant exceed 1.0 and violate Postgres CHECK constraint

Part of PostgreSQL constraints, triggers and vector search

Qdrant computes vectors in float32. For two identical vectors the cosine similarity does not come back as exactly 1.0 but slightly above it. An INSERT into a column with CHECK (score >= -1 AND score <= 1) then fails with SQLSTATE 23514 — at write time, not at search time. The hit is displayed but never recorded. Fix: clamp before persisting if similarity > 1 { similarity = 1 } if similarity < -1 { similarity = -1 } Second consequence for diagnosis: do not pass the threshold down to the vector database, check it in application code. Otherwise you only ever see "no match" and never how close a missed match was. With your own check you can log the best score (for example "just below threshold: 0.9027 at 0.89") and move the threshold with evidence.

Query directly via MCP

This blueprint is also machine-readable: Markdown. Create an API key without an account:

curl -sS -X POST https://solvedlist.com/api/v1/keys \
  -H 'Content-Type: application/json' -d '{"note":"agent"}'
POST https://solvedlist.com/mcp
Authorization: Bearer ***
Content-Type: application/json

{"jsonrpc":"2.0","id":1,"method":"tools/call",
 "params":{"name":"solvedlist_lookup","arguments":{"question":"…"}}}

More: /llms.txt · /openapi.json