AI & LLM

Vector Database Search Query JSON Example

A JSON example of a vector database query and response — includes the query vector, topK, metadata filter, and ranked matches with scores. Copy-ready for Pinecone, Qdrant, and pgvector.

{
  "matches": [
    {
      "id": "doc_4821#chunk_3",
      "score": 0.8731,
      "metadata": {
        "title": "Resetting your password",
        "source": "help-center/account.md"
      }
    },
    {
      "id": "doc_1190#chunk_0",
      "score": 0.7402,
      "metadata": {
        "title": "Password requirements",
        "source": "help-center/security.md"
      }
    }
  ],
  "namespace": "help-center"
}

Field Reference

matchesrequiredarray<object>Nearest-neighbour results, ordered by score descending
matches[].idrequiredstringIdentifier of the stored vector/record
matches[].scorerequirednumberSimilarity score (cosine/dot-product); higher means more similar
matches[].metadataoptionalobjectAttributes stored with the vector — used for display, citation, and filtering
namespaceoptionalstringLogical partition the query ran against

Variants

Query requestSearch by an embedding vector, limit results with topK, and filter on metadata.
{
  "vector": [
    0.0023064255,
    -0.009327292,
    0.015797347,
    -0.0073122089
  ],
  "topK": 5,
  "includeMetadata": true,
  "filter": {
    "source": {
      "$eq": "help-center/account.md"
    }
  },
  "namespace": "help-center"
}
Upsert requestInsert or update vectors with their metadata.
{
  "vectors": [
    {
      "id": "doc_4821#chunk_3",
      "values": [
        0.0023,
        -0.0093,
        0.0157
      ],
      "metadata": {
        "title": "Resetting your password"
      }
    }
  ],
  "namespace": "help-center"
}

Common Use Cases

  • Querying a vector database for semantically similar documents
  • Powering retrieval in a RAG pipeline with metadata filtering
  • Building recommendation and deduplication features on embeddings
vector databasepineconeqdrantsemantic searchsimilarityrag

Validate or format this JSON

One click loads this exact example into the tool — no copy-paste needed. Format it, validate it, explore the tree, or generate TypeScript types instantly.

Frequently Asked Questions

topK is the number of nearest neighbours to return — e.g. topK: 5 returns the five most similar vectors by score. For RAG you typically retrieve a small topK (3–10), then optionally re-rank before building the LLM context.

You attach metadata (source, date, tenant, access level) to each vector at upsert time, then pass a filter in the query so only matching vectors are considered. This enables multi-tenant isolation, recency filters, and permission-aware retrieval.

It depends on the metric. Cosine similarity ranges from -1 to 1 (usually 0 to 1 for text embeddings); dot product is unbounded; Euclidean distance is 0+ where lower is closer. Always check which metric your index uses before thresholding.

Related JSON Examples