Documents
Search Documents
Search your database using text or images. Vecstore performs semantic search across text-to-text, image-to-image, and text-to-image, returning the most relevant documents ranked by similarity.
Request
Replace {id} in the path with your database ID and send a JSON body like this one.
{
"content": "kitchen faucet repair",
"metadata": {
"category": "home-repair"
},
"top_k": 10,
"page": 1,
"per_page": 5,
"min_score": 0.3
}Query ·optional
Without a query, documents are listed newest first.
Filters ·optional
Pagination ·optional
top_kFacets ·optional
top_k if larger. Without one: matching documents, up to 50,000, defaulting to 10,000 Response
Returns a page of results, best match first.
{
"results": [
{
"id": "4de5bed5-e483-4bd7-9760-a54ec07aefd9",
"content": "How to fix a leaky kitchen faucet",
"metadata": {
"category": "home-repair"
},
"score": 0.92
},
{
"id": "7f8e9a0b-1c2d-3e4f-5a6b-7c8d9e0f1a2b",
"content": "Replacing a kitchen sink tap",
"metadata": {
"category": "plumbing"
},
"score": 0.87
}
],
"page": 1,
"per_page": 5,
"estimated_total": 10,
"has_more": true,
"search_time": "4ms",
"embedding_ms": 9.8
}Each result
null for images keyword mode Paging and timing
estimated_total in filtered searches without a query that match fewer than 10,000 documents Facets
Only returned when the request includes facets.
min, max and avg for keys with numeric values true if every match was counted, false if counting stopped at facet_depthSearch Modes
Text databases support three ways of matching a content query, set with mode. Every mode costs 1 credit per search. Modes apply to text databases. Image databases always use semantic search.
{
"content": "SKU-48213",
"mode": "keyword",
"top_k": 10
}Pagination
top_k caps how many results you can page through, and per_page sets how many come back per request. The first page of a top_k of 1000 is as fast as a top_k of 10; later pages cost more. Keep raising page while has_more is true.
{
"content": "running shoes",
"top_k": 100,
"page": 1,
"per_page": 10
}Metadata Filters
Match a field to one value, to any value in a list with $in, or to a numeric range. All of them can be combined in one request, and a document must match every field.
"metadata": {
"category": "shoes",
"brand": { "$in": ["nike", "salomon"] },
"price": { "$gte": 50, "$lte": 150 }
}Operators
Matching rules
- Fields stored as arrays match if any element matches, so
"color": "black"finds documents with"color": ["black", "red"]. - Values are compared by type after converting text that looks like a number or boolean, so
"42"matches42and"true"matchestrue. - Ranges only match numbers. Documents where the field is text, missing or
nullare left out. On arrays, one element must satisfy every bound. $intakes up to 1000 strings, numbers or booleans. Empty lists are rejected.- Unknown operators and non-numeric bounds return
400. Keys must match[a-zA-Z0-9_-]{1,64}.
Tip: equality and $in filters use an index, ranges don't. In a metadata-only search, add at least one equality filter next to a range on large databases, so the range only checks the documents that already match.
Facets
List metadata keys in facets to get a count of each value across your results, for building filter sidebars like brand, color or size. Counts cover the top top_k results on every page, not just the page returned, so they match exactly what a user can page through. Facets cost no extra credits.
{
"content": "trail running shoes",
"metadata": { "in_stock": true },
"facets": ["brand", "color", "price"],
"max_facet_values": 5,
"top_k": 200,
"per_page": 20
}{
"results": [
{
"id": "4de5bed5-e483-4bd7-9760-a54ec07aefd9",
"content": "Salomon Speedcross 6 trail running shoe",
"metadata": {
"brand": "salomon",
"color": ["black", "red"],
"price": 139.99,
"in_stock": true
},
"score": 0.97
}
],
"page": 1,
"per_page": 20,
"estimated_total": 200,
"has_more": true,
"facets": {
"brand": { "salomon": 74, "nike": 61, "hoka": 38 },
"color": { "black": 88, "grey": 51, "blue": 34, "red": 29, "green": 12 },
"price": { "129.99": 21, "139.99": 17, "99.99": 15, "159": 12, "119": 9 }
},
"facet_stats": {
"price": { "min": 59.99, "max": 249.0, "avg": 132.4 }
},
"facets_exhaustive": true,
"search_time": "12ms",
"embedding_ms": 9.8
}How values are counted
- Each document counts once per value. For arrays, every distinct element counts, so a shoe in sizes
[42, 43]adds 1 to both. - Strings, numbers and booleans are counted. Nested objects and
nullare skipped. - Values come back as strings, most common first, ties in alphabetical order. Send one back as a metadata filter as-is:
"42"matches the number42. - Every requested key appears in
facets, as{}if no result has it.facet_statsonly lists keys with numeric values.
Facets with filters
Facets are counted after metadata filters, so filtering on brand leaves only the selected brands in the brand counts. To keep showing every option for a facet while it's selected, send a second request without that filter and read its counts.
Facets for the whole database
Leave out the query to count values across every document, or send only a metadata filter to count across the documents that match it. Up to facet_depth documents are counted, 10,000 by default. Past that, facets_exhaustive is false:
- Without a filter, counts come from a random sample and are scaled up to the size of the database. Rare values can be missing.
- With a filter, counts cover the first
facet_depthmatching documents.
{
"facets": ["brand", "color", "price"],
"per_page": 20
}Note: with a query, every page searches the full top_k, so keep top_k as small as your UI needs. Keys must match [a-zA-Z0-9_-]{1,64}.
Find Similar
Send a document's ID as similar_to in place of a query to find documents like it. The stored embedding is reused, so the search is faster, and the source document is left out of the results. Works on text and image databases, with or without a metadata filter. Returns 404 if the ID doesn't exist.
{
"similar_to":"4de5bed5-e483-4bd7-9760-a54ec07aefd9",
"top_k": 10
}Metadata-Only Search FREE
Leave out content, image, image_url and similar_to to filter by metadata alone. No embedding or vector search runs, so no credit is charged. Every score is 0.0, and you get an exact total instead of estimated_total.
{
"metadata": {
"type": "variant",
"product_id": { "$in": [321, 123] }
},
"page": 1,
"per_page": 20
}Filtering by Score
Set min_score to drop weak matches instead of always getting top_k results. Low scores are removed before pagination, so fewer results may come back. It has no effect on metadata-only searches and returns 400 in keyword mode.
| Search | Score | Good starting point |
|---|---|---|
| Text → image | Calibrated, 0 to 1 | 0.3 |
| Image → image | Cosine similarity | 0.6 |
| Text → text, hybrid | 1.0 if ranked first by both | – |
| Text → text, semantic | Cosine similarity | – |