Mixedbread

Grep Store Chunks

Match store chunks against a regular expression. Unlike `/stores/search`, this runs your regex against the literal text of each chunk. Use it to find chunks containing a specific token, identifier, error code, or literal phrase.

POST
/v1/stores/grep

Unlike /stores/search, this runs your regex against the literal text of each chunk. Use it to find chunks containing a specific token, identifier, error code, or literal phrase.

grep matches across all requested stores and returns at most top_k chunks in total. Matches are unranked and interleaved across stores in the order requested, preserving each store's result order. Pagination is not supported; raise top_k to retrieve more matches.

Authorization

ApiKeyAuth
headerAuthorizationBearer <token>

Api key to access Mixedbreads API

Header Parameters

X-Mxbai-Tool-Ticket?|

Ticket from a chat completion's tool_tickets, proving this call runs a tool call that completion asked for. Redeems once, and bills the operation at the discounted agent rate.

Request Body

application/json
  1. body

Grep parameters including the regular expression pattern, targets and filters

store_identifiers*array<string|>

IDs or names of stores

Items1 <= items <= 64
top_k?Top K

Number of results to return

Range1 <= value <= 10000
Default10
filters?||array<|>|

Optional filter conditions

file_ids?array<any>|array<>|

Optional list of file IDs to filter chunks by (inclusion filter)

pattern*Pattern

Regular expression (RE2 syntax) matched against chunk text

Length1 <= length <= 1024
targets?array<>

Chunk content groups to match against. text matches the original text of text chunks; generated matches ingestion-derived fields (transcription, OCR text, summaries).

Items1 <= items
case_sensitive?Case Sensitive

Whether the regular expression is case-sensitive

Defaultfalse
return_metadata?Return Metadata

Whether to return file metadata

Defaulttrue

Response Body

List of chunks whose text matches the pattern

application/json
  1. response
object?Object

The object type of the response

Default"list"
data*array<|||>

The list of chunks matching the pattern

Example Request
from mixedbread import Mixedbread

mxbai = Mixedbread(api_key="YOUR_API_KEY")

response = mxbai.stores.grep(
    store_identifiers=["{{STORE_IDENTIFIER}}"],
    pattern="ERR-\\d{4}",
    top_k=10,
)

for chunk in response.data:
    print(chunk)
Example Response
{
  "object": "list",
  "data": [
    {
      "chunk_index": 3,
      "mime_type": "text/plain",
      "model": "mxbai-omni",
      "score": 1,
      "file_id": "f47ac10b-58cc-4372-a567-0e02b2c3d479",
      "filename": "error_logs.txt",
      "store_id": "c3d4e5f6-a7b8-9012-cdef-345678901234",
      "metadata": {
        "source": "upload",
        "page": 2
      },
      "type": "text",
      "text": "Encountered ERR-4021 while processing the request payload."
    },
    {
      "chunk_index": 7,
      "mime_type": "text/plain",
      "model": "mxbai-omni",
      "score": 1,
      "file_id": "b2c3d4e5-f6a7-8901-bcde-f23456789012",
      "filename": "incident_report.md",
      "store_id": "c3d4e5f6-a7b8-9012-cdef-345678901234",
      "metadata": {
        "category": "ops"
      },
      "type": "text",
      "text": "Root cause analysis points to ERR-1337 raised by the upstream service."
    }
  ]
}