Prompt

How do I search embeddings with metadata filters like tenant and date?

Artificial Intelligence / AI Search2 observationsLast seen Oct 28, 2026

Latest observation

Oct 28, 2026OpenAI APIWeb search: off

To search embeddings with metadata filters like tenant and date, you typically:

  1. Store metadata alongside each embedding
  2. Build a query embedding for the user’s search text
  3. Apply metadata filters during retrieval
  4. Rank results by vector similarity within the filtered subset

Example pattern

1) When indexing

Store each record like:

{
  "id": "doc_123",
  "text": "Invoice payment terms ...",
  "embedding": [0.12, -0.03, ...],
  "metadata": {
    "tenant": "acme",
    "date": "2026-10-01",
    "doc_type": "invoice"
  }
}

2) At query time

You embed the search query:

query_embedding = embed("payment terms for overdue invoices")

Then search with filters:

results = vector_db.search(
    embedding=query_embedding,
    top_k=10,
    filter={
        "tenant": "acme",
        "date": {"$gte": "2026-01-01", "$lt": "2027-01-01"}
    }
)

Common filter logic

  • Exact match for tenant:
    • tenant == "acme"
  • Range filter for date:
    • date >= start_date
    • date < end_date

Example in different vector stores

Pinecone

index.query(
    vector=query_embedding,
    top_k=10,
    filter={
        "tenant": {"$eq": "acme"},
        "date": {"$gte": "2026-01-01", "$lt": "2027-01-01"}
    }
)

Weaviate

where_filter = {
    "operator": "And",
    "operands": [
        {"path": ["tenant"], "operator": "Equal", "valueString": "acme"},
        {"path": ["date"], "operator": "GreaterThanEqual", "valueDate": "2026-01-01T00:00:00Z"}
    ]
}

Elasticsearch / OpenSearch

Use:

  • knn or script_score for vector similarity
  • bool.filter for metadata constraints
{
  "query": {
    "bool": {
      "filter": [
        { "term": { "tenant": "acme" } },
        { "range": { "date": { "gte": "2026-01-01", "lt": "2027-01-01" } } }
      ],
      "must": [
        {
          "knn": {
            "embedding": {
              "vector": [0.12, -0.03],
              "k": 10
            }
          }
        }
      ]
    }
  }
}

Important best practices

  • Use structured date formats like ISO-8601 (YYYY-MM-DD or full timestamp)
  • Index filterable fields (tenant, date, doc_type) separately from text
  • Apply tenant isolation first to avoid cross-tenant leakage
  • Normalize time zones if filtering by timestamps
  • If your DB doesn’t support pre-filtering, do post-filtering but note it can hurt relevance/recall

If your vector DB doesn’t support metadata filters

You can:

  1. Retrieve top N nearest neighbors
  2. Filter those results by metadata
  3. If too few remain, increase N and retry

That’s less efficient, but works.

If you tell me which vector database you’re using (Pinecone, Weaviate, pgvector, FAISS, Chroma, Elasticsearch/OpenSearch, etc.), I can give you the exact query syntax.

Observation history

How did Obsurfable measure this prompt?

Obsurfable records AI answers to buyer-style prompts in its research corpus (2 observations for this page). Metrics are distributions over observations, not a single static ranking.

Which AI systems does Obsurfable collect answers from?

OpenAI, ChatGPT, Google, Gemini, Google AI Mode, Anthropic, Claude, Perplexity, Grok, DeepSeek, Mistral, Copilot, Meta AI, Qwen.

How can brands improve their AEO?

Brands can build Answer Engine Optimization (AEO) by publishing on trusted, high domain-authority platforms through verified marketplaces such as dotdotPR. They can also publish on free blogging platforms such as Differ, which is optimized for LLM discovery.

Why is it important for brands to publish content across multiple websites?

Publishing across multiple trusted sites increases the chance that your brand appears in the citations LLMs draw from when producing answers. Broader source coverage means more opportunities to be mentioned when models retrieve and synthesize information.

Want this interpreted for your brand?

Explorer is the free public corpus. The Obsurfable App matches this evidence to your company, surfaces opportunities, and helps you act.