Skip to Content
Mixedbread

Search

Learn how to search your Store with semantic queries, configuration options, and advanced filtering capabilities.

Search your Store using natural language to find exactly what you need. Stores understand the meaning behind your queries, not just keywords, making it perfect for conversational search and complex questions.

Search for chunks of content across your Store:

Search Store
from mixedbread import Mixedbread

mxbai = Mixedbread(api_key="YOUR_API_KEY")

response = mxbai.stores.search(
    query="How does authentication work?",
    store_identifiers=["my-knowledge-base"],
    top_k=5,
)

for chunk in response.data:
    print(chunk)

When you search, Stores understand your natural language query and find the most relevant content across all your files. Results are automatically ranked by relevance with confidence scores.

For complete details on chunk object structure including all content types and properties, see Data Models.

Search Options

Top-k Results

Control the number of results returned:

Top-k Results
results1 = mxbai.stores.search(
  query="API authentication methods",
  store_identifiers=["docs"],
  top_k=5
)

results2 = mxbai.stores.search(
  query="deployment strategies",
  store_identifiers=["docs"],
  top_k=20
)

Optimization Tips:

  • Start with top_k=10 for most use cases
  • Increase for comprehensive searches
  • Decrease for faster response times

Filter

Filter search results to narrow down your search scope. Store search supports two types of filtering:

Metadata Filtering
results = mxbai.stores.search(
  query="user authentication",
  store_identifiers=["docs"],
  filters={
      "all": [
          {"key": "category", "operator": "eq", "value": "documentation"},
          {"key": "difficulty", "operator": "in", "value": ["beginner", "intermediate"]}
      ]
}
)

For complete metadata filtering capabilities and advanced patterns, see Metadata Filtering.

File Filtering
results1 = mxbai.stores.search(
  query="authentication methods",
  store_identifiers=["docs"],
  file_ids=["123e4567-e89b-12d3-a456-426614174000", "123e4567-e89b-12d3-a456-426614174001"]
)

results2 = mxbai.stores.search(
  query="authentication methods",
  store_identifiers=["docs"],
  file_ids=("in", ["123e4567-e89b-12d3-a456-426614174000"])
)

results3 = mxbai.stores.search(
  query="authentication methods",
  store_identifiers=["docs"],
  file_ids=("not_in", ["123e4567-e89b-12d3-a456-426614174000"])
)

Rerank

Improve search result quality by reranking results with specialized models:

Reranking Examples
results = mxbai.stores.search(
  query="API rate limiting best practices",
  store_identifiers=["docs"],
  search_options={
      "rerank": True
  }
)

Reranking applies a second-stage ranking model to improve relevance, especially useful for complex queries or when initial results need refinement. You can use simple boolean (True) or configure advanced options with model selection and metadata inclusion.

Learn more about Rerank for advanced reranking strategies and model options.

Rewrite Query

Let a specialized AI model rewrite your query to get the most optimal semantic search experience. It automatically applies best practices like adding more context and using full semantic qualifiers instead of keywords.

Rewrite Query
results = mxbai.stores.search(
  query="machine learning deployment",
  store_identifiers=["documentation"],
  top_k=15,
  search_options={
      "rewrite_query": True
  },
)

You can get the rewritten query by calling the /v1/stores/{store_identifier}/events endpoint.

Considerations:

  • The latency increases due to additional agent calls
  • Not every query needs to be rewritten

Search across multiple Stores simultaneously:

Multi Store Search
results = mxbai.stores.search(
  query="machine learning deployment",
  store_identifiers=[
      "documentation",
      "research-papers",
      "tutorials",
      "code-examples"
      ],
  top_k=15
)

Considerations:

  • Results are merged and re-ranked together
  • May need higher top_k for diverse results
  • Different Stores may have different metadata schemas

Balance Results Across Stores

By default a multi store search keeps the best top_k chunks across all Stores, so one large Store can fill the results on its own and crowd out relevant chunks from a smaller one. Set candidates_per_store to search each Store on its own and pool its best candidates_per_store chunks. The search returns the best top_k chunks of that pool, ordered by the reranker when rerank is set and by search score otherwise.

Balanced Multi Store Search
results = mxbai.stores.search(
  query="machine learning deployment",
  store_identifiers=[
      "documentation",
      "research-papers",
      "tutorials",
      "code-examples"
      ],
  top_k=10,
  search_options={
      "candidates_per_store": 5,
      "rerank": True
  }
)

Here each of the four Stores contributes its best 5 chunks, and the reranker picks the best 10 of those 20.

  • Returns fewer than top_k results when the Stores contribute fewer chunks in total
  • candidates_per_store times the number of Stores may not exceed 10,000
  • Not supported with agentic search or the web store

For complex questions that need multiple sources, an agent can plan, run, and rank a series of searches for you in a single call:

Agentic Search
from mixedbread import Mixedbread

mxbai = Mixedbread(api_key="YOUR_API_KEY")

results = mxbai.stores.search(
    query="What are the yearly numbers for 2020, 2021, 2022, 2023, 2024, 2025?",
    store_identifiers=["yearly-reports"],
    search_options={"agentic": True},
)

print(results)

The response shape matches a normal search. See Agentic Search for the full parameter reference, configuration examples, and how to inspect the agent's tool calls and token usage via the events endpoint.

Additional options let you steer the agent and the result shape:

  • strict_top_k (default true when top_k is set, else false): return the top_k most relevant chunks the agent found. Set to false to return only chunks the agent considers relevant.
  • instructions: free-form guidance for the agent, e.g. preferred source types or ranking criteria.

Search the web using the same API by including mixedbread/web as a store identifier. You can use it standalone or combine it with your own stores for hybrid search that merges web results with your internal knowledge base.

Web Search
from mixedbread import Mixedbread

mxbai = Mixedbread(api_key="YOUR_API_KEY")

results = mxbai.stores.search(
    query="latest AI research papers",
    store_identifiers=["mixedbread/web", "internal-docs"],
    top_k=10,
)

print(results)

For detailed web search capabilities and response format, see Web Store.