Vector Search
Flux can compare semantic meaning—not just keywords—by generating embeddings for your content and your search queries. This guide explains when to enable vector search, how each mode works, and how to configure _search requests even if you have never worked with vectors before.
Prerequisites
- Vectorizable fields – Mark relevant
stringortextfields withvectorizable=truein the Fields API. Flux only stores embeddings for those fields. - Re-save content – Existing resources must be republished after you enable vectorization so embeddings can be generated.
_searchreturns no vector matches until the content has embeddings. - Vector storage – Embeddings consume vector storage units (see Resources API). Running out of units causes writes to fail with
insufficient_units. - Flux search endpoint – Vector queries run through the same
_searchendpoint as traditional filters.
Choosing a Mode
| Mode | When to use | Requirements |
|---|---|---|
text | Default keyword/phrase search | No vector_search payload allowed. |
vector | Pure semantic results (ignore text search entirely) | vector_search required. Do not send find_text or find_phrase. |
vector_boosted | Keyword results ranked first, vector scores boost relevant items | Requires both vector_search and either find_text or find_phrase. Optional vector_boost_config. |
hybrid | Blend text + vector results with explicit weights | Requires vector_search plus find_text or find_phrase. Optional hybrid_config. |
Use vector when you want purely semantic results (e.g., “inspiration photos that feel cozy”). Use vector_boosted or hybrid when you still care about keyword relevance but want semantic refinement.
vector_search Parameters
- Name
query- Type
- string
- Required
- required
- Description
The natural-language text to embed (min length 3, truncated to 1,000 characters).
- Name
fields- Type
- array
- Description
Optional list of vectorized fields to search. Omit to search all vectorizable fields.
- Name
top_k- Type
- integer
- Default
- default:10
- Description
Number of semantic neighbors to retrieve (max 100). Defaults to 10 when omitted.
- Name
similarity_threshold- Type
- number
- Default
- default:0.7
- Description
Minimum cosine similarity (0–1). Lower values return fuzzier matches. Defaults to 0.7 when omitted.
These values go inside the _search body:
"search_mode": "vector",
"vector_search": {
"query": "cozy modern living room inspiration",
"fields": ["body"],
"top_k": 25,
"similarity_threshold": 0.65
}
Flux automatically generates an embedding for query, compares it to your stored embeddings, and returns the closest matches.
Boost & Hybrid Controls
When you mix text and vector search, you can fine-tune how vector results influence ranking.
vector_boost_config
"vector_boost_config": {
"boost_factor": 1.2,
"similarity_threshold": 0.8,
"max_boost_results": 20
}
boost_factoramplifies vector hits relative to text-only results (defaults to 1.5).similarity_thresholdensures only strong matches boost the score.max_boost_resultscaps how many results get boosted.
hybrid_config
"hybrid_config": {
"vector_weight": 0.6,
"text_weight": 0.4,
"rerank_results": true
}
- Set weights to control how vector vs text scores are combined (defaults: 0.6 / 0.4).
rerank_results=truesorts by the combined score; set tofalseto keep text order and annotate with hybrid scores.
Examples
1. Pure Vector Search
curl -X POST \
"https://7c9h4pwu.fxns.io/gallery/projects/_search" \
-H "Authorization: Secure <access_key>:<signature>" \
-H "Content-Type: application/json" \
-d '{
"search_mode": "vector",
"vector_search": {
"query": "warm minimalist living room",
"fields": ["description"],
"top_k": 30,
"similarity_threshold": 0.7
}
}'
2. Vector-Boosted Keyword Search
{
"search_mode": "vector_boosted",
"find_text": {
"query": "sofa",
"fields": ["title", "summary"]
},
"vector_search": {
"query": "comfortable modern sofa",
"fields": ["body"]
},
"vector_boost_config": {
"boost_factor": 1.3,
"similarity_threshold": 0.75,
"max_boost_results": 15
}
}
Flux runs the text search first, then boosts matches whose embeddings are semantically similar to the vector query.
3. Hybrid Search
{
"search_mode": "hybrid",
"find_phrase": {
"query": "content strategy",
"fields": ["title"]
},
"vector_search": {
"query": "content marketing playbook",
"fields": ["body"]
},
"hybrid_config": {
"vector_weight": 0.5,
"text_weight": 0.5,
"rerank_results": true
}
}
Hybrid combines both scores into a new field (metadata.score in the response) and sorts by the weighted score when rerank_results is true.
Vector Field Search
vector_field_search lets you bring your own embeddings instead of relying on Flux-generated ones. This is useful when you already have an embedding pipeline (e.g., OpenAI, Cohere, or a custom model) and want to store and query vectors directly.
Prerequisites
- Create a vector field – Add a field with
type: "vector"andmeta.dimensionsset to one of the supported sizes (256, 384, 768, 1024, 1536) via the Fields API. - Store embeddings – Include the embedding array when creating or updating resources. The array length must match the field's configured dimensions.
- Republish – Resources must be published after adding vector data.
vector_field_search Parameters
- Name
field- Type
- string
- Required
- required
- Description
The key of the vector field to search against (e.g.,
"custom_embedding").
- Name
query_vector- Type
- array of numbers
- Required
- required
- Description
Your pre-computed embedding vector. Length must match the field's
dimensionsand be one of: 256, 384, 768, 1024, 1536.
- Name
top_k- Type
- integer
- Default
- default:10
- Description
Number of nearest neighbors to retrieve from the vector index (1–200).
- Name
similarity_threshold- Type
- number
- Default
- default:0.0
- Description
Minimum cosine similarity (0–1). Only results above this threshold are returned.
Supported Modes
vector_field_search works with search_mode set to "vector" or "vector_boosted":
| Mode | Behavior |
|---|---|
vector | Pure vector search using your embeddings. find_text/find_phrase are not allowed. |
vector_boosted | Text search results boosted by vector similarity. Requires find_text or find_phrase. Optional vector_boost_config. |
hybrid mode is not supported with vector_field_search. Use vector_search (auto-generated embeddings) for hybrid queries.
Why no hybrid mode? Hybrid search blends text relevance and vector similarity into a single weighted score, which assumes both scores measure the same thing — how well the content matches the user's textual query. With vector_search, FoxNose generates the query embedding from the same natural-language input, so this assumption holds. With vector_field_search, however, the query_vector can represent anything — a speaker voiceprint, an image feature, a product attribute — making a weighted combination with a text score semantically meaningless. Use vector_boosted instead: it keeps text ranking as the primary signal and applies a cosine-similarity boost on top, which works correctly regardless of what the embeddings represent.
Constraints
vector_field_searchandvector_searchare mutually exclusive — you cannot use both in the same request.- The
query_vectordimension must exactly match the field's configureddimensions. A mismatch returns422 validation_error. - If the specified
fielddoes not exist or is not a vector type, the request returns422 invalid_request.
Examples
Pure Vector Field Search
curl -X POST \
"https://7c9h4pwu.fxns.io/ml/speakers/_search" \
-H "Authorization: Secure <access_key>:<signature>" \
-H "Content-Type: application/json" \
-d '{
"search_mode": "vector",
"vector_field_search": {
"field": "speaker_embedding",
"query_vector": [0.012, -0.034, 0.056, ...],
"top_k": 20,
"similarity_threshold": 0.6
}
}'
Vector-Boosted with Custom Embeddings
{
"search_mode": "vector_boosted",
"find_text": {
"query": "keynote speaker AI",
"fields": ["bio", "topics"]
},
"vector_field_search": {
"field": "speaker_embedding",
"query_vector": [0.012, -0.034, 0.056, ...],
"top_k": 30,
"similarity_threshold": 0.5
},
"vector_boost_config": {
"boost_factor": 1.3,
"similarity_threshold": 0.7,
"max_boost_results": 15
}
}
Text results are ranked first, then boosted by cosine similarity to your embedding vector.
Vector Field Search with Filters
{
"search_mode": "vector",
"vector_field_search": {
"field": "product_embedding",
"query_vector": [0.012, -0.034, 0.056, ...],
"top_k": 50,
"similarity_threshold": 0.5
},
"where": {
"$": {
"all_of": [
{"category__eq": "electronics"},
{"in_stock__eq": true}
]
}
}
}
Filters are applied after vector retrieval, narrowing results to matching documents.
Scoring
Each result includes a relevance score in _sys.relevance. The formula depends on the search mode:
| Mode | Score formula | Range |
|---|---|---|
vector | Cosine similarity between query_vector and stored embedding | 0 to 1 |
vector_boosted | similarity × boost_factor, capped at 1.0 | 0 to 1 |
top_k controls how many nearest neighbors the vector index retrieves internally — it is not the final result count. Flux may fetch more candidates than top_k to support filtering and pagination. The actual number of results returned is governed by limit. When combining VFS with where filters, set top_k to 3–5× your expected result count, since post-filtering may discard vector candidates that don't match filter conditions.
Scenarios
vector_field_search composes naturally with filters, sorting, pagination, and boost tuning. Below are common combinations.
Filtered Vector Search
Find similar speakers who match specific criteria:
{
"search_mode": "vector",
"vector_field_search": {
"field": "speaker_embedding",
"query_vector": [0.012, -0.034, 0.056, "...768 floats..."],
"top_k": 50,
"similarity_threshold": 0.5
},
"where": {
"$": {
"all_of": [
{"gender__eq": "female"},
{"years_experience__gte": 5}
]
}
}
}
Filters are applied after vector retrieval. If too few results come back, increase top_k or loosen similarity_threshold.
Boosted Search with Phrase Match
Find articles containing an exact phrase, boosted by topic embedding similarity:
{
"search_mode": "vector_boosted",
"find_phrase": {
"query": "machine learning",
"fields": ["title", "abstract"]
},
"vector_field_search": {
"field": "topic_embedding",
"query_vector": [0.023, -0.011, 0.089, "...384 floats..."],
"top_k": 25
}
}
find_phrase works identically to find_text in boosted mode. Phrase matches are ranked first, then boosted by vector similarity.
Tuning Boost Behavior
Control how aggressively vector scores influence ranking:
{
"search_mode": "vector_boosted",
"find_text": {
"query": "sustainable packaging",
"fields": ["description"]
},
"vector_field_search": {
"field": "product_embedding",
"query_vector": [0.045, -0.022, 0.067, "...384 floats..."],
"top_k": 40,
"similarity_threshold": 0.3
},
"vector_boost_config": {
"boost_factor": 2.0,
"similarity_threshold": 0.6,
"max_boost_results": 10
}
}
In vector_boosted mode, vector_boost_config takes precedence over VFS parameters. Here, even though VFS specifies similarity_threshold: 0.3 and top_k: 40, the boost config narrows the boosted pool to 10 results above 0.6 similarity. Set your intended thresholds in vector_boost_config rather than in vector_field_search to avoid confusion.
Custom Sort Order
Find similar products, break ties by price:
{
"search_mode": "vector",
"vector_field_search": {
"field": "product_embedding",
"query_vector": [0.012, -0.034, 0.056, "...384 floats..."],
"top_k": 50
},
"sort": ["price"]
}
Results are ordered by vector similarity first. The sort parameter acts as a tiebreaker when two documents have equal similarity scores.
Paginated Vector Search
Browse similar items page by page:
{
"search_mode": "vector",
"vector_field_search": {
"field": "image_embedding",
"query_vector": [0.012, -0.034, 0.056, "...768 floats..."],
"top_k": 100,
"similarity_threshold": 0.4
},
"limit": 20
}
The response includes pagination URLs:
{
"limit": 20,
"next": "https://example.fxns.io/ml/images/_search?next=abc123&limit=20",
"previous": null,
"results": ["..."]
}
Pass the next URL to retrieve the following page. Pagination works identically to all other search modes — see Pagination for details.
Full Combination
Find similar electronics in stock under $500, sorted by price, paginated:
{
"search_mode": "vector",
"vector_field_search": {
"field": "product_embedding",
"query_vector": [0.012, -0.034, 0.056, "...384 floats..."],
"top_k": 100,
"similarity_threshold": 0.4
},
"where": {
"$": {
"all_of": [
{"category__eq": "electronics"},
{"in_stock__eq": true},
{"price__lte": 500}
]
}
},
"sort": ["price"],
"limit": 10
}
All features compose naturally: vector retrieval selects candidates, filters narrow them down, sort acts as a tiebreaker, and pagination slices the result set. Request the next page with ?next=<cursor>&limit=10.
When to Use vector_field_search vs vector_search
vector_search | vector_field_search | |
|---|---|---|
| Embeddings | Auto-generated by Flux | User-provided |
| Input | Natural-language query string | Pre-computed query_vector array |
| Setup | Mark fields as vectorizable | Create a vector type field, store arrays |
| Hybrid mode | Supported | Not supported (scores are not comparable) |
| Use case | Content search, semantic Q&A | Speaker diarization, image similarity, custom ML models |
Reading the Response
Every search response includes a metadata object with the effective parameters that were used, including any server-side defaults.
The shape varies by mode:
vector mode
"metadata": {
"search_mode": "vector",
"limit": 100,
"vector_search_enabled": true,
"top_k": 10,
"similarity_threshold": 0.4
}
hybrid mode
"metadata": {
"search_mode": "hybrid",
"limit": 100,
"vector_search_enabled": true,
"top_k": 10,
"similarity_threshold": 0.4,
"text_threshold": 0.85,
"vector_weight": 0.6,
"text_weight": 0.4
}
vector_boosted mode
"metadata": {
"search_mode": "vector_boosted",
"limit": 100,
"vector_search_enabled": true,
"top_k": 5,
"similarity_threshold": 0.6,
"text_threshold": 0.8,
"boost_factor": 1.5,
"boost_similarity_threshold": 0.6,
"max_boost_results": 5
}
text mode
"metadata": {
"search_mode": "text",
"limit": 100,
"text_threshold": 0.85
}
When using vector_field_search, the metadata also includes a vector_field_search sub-object:
vector_field_search
"metadata": {
"search_mode": "vector",
"limit": 100,
"vector_search_enabled": true,
"top_k": 10,
"similarity_threshold": 0.4,
"vector_field_search": {
"field": "speaker_embedding",
"dimension": 768,
"top_k": 30,
"similarity_threshold": 0.5,
"distance_metric": "cosine"
}
}
Best Practices
- Start with a smaller
top_k(10–25) to keep responses fast. Increase only when needed. - Tune
similarity_threshold– the default is 0.4; raise it for stricter matches or lower for broader recall. - Keep
limit≥top_k– Flux returns up tolimitdocuments. Iftop_kis higher thanlimit, extra vector hits will be dropped. - Monitor storage usage – The
_sys.vectors_sizefield in the Resources API helps track vector storage consumption. - Handle validation errors – Missing vector payload (
vector_searchorvector_field_search) when required, combiningfind_textwithsearch_mode="vector", or usingvector_field_searchwithsearch_mode="text"all return422 validation_error. Checkerror_codefor exact causes. - Expect higher latency for narrow filters – Combining vectors with restrictive
where__filters or joins forces Flux to scan more data to find matches. Loosen filters or lower thresholds if queries become slow. - Increase
top_kwhen using VFS with filters –whereconditions are applied after vector retrieval. Settop_kto 3–5× your expected result count so enough candidates survive post-filtering. - Set boost thresholds in
vector_boost_config– Invector_boostedmode,vector_boost_config.similarity_thresholdandmax_boost_resultsoverride the corresponding VFS parameters. Define your intended thresholds there to avoid confusion.
Troubleshooting
| Symptom | Possible cause | Fix |
|---|---|---|
vector_search_enabled=false in the response | Content lacks embeddings (field not vectorized or resource not re-saved) | Enable vectorizable on the field and republish resources. |
422 validation_error mentioning vector search | Missing required vector payload (vector_search or vector_field_search) or using find_text when search_mode="vector" | Update the request to match the mode requirements. |
422 validation_error mentioning text search mode | vector_field_search used with search_mode="text" | Use search_mode="vector" for pure vector retrieval, or search_mode="vector_boosted" with find_text/find_phrase. |
| No results despite relevant content | similarity_threshold too high or fields too narrow | Lower the threshold or remove the fields filter. |
| Billing errors when creating content | Vector storage quota exceeded | Purchase more units or disable vectorization on non-essential fields. |
422 validation_error mentioning dimension | query_vector length does not match field dimensions | Ensure the vector length matches the field's configured dimension (256, 384, 768, 1024, or 1536). |
422 invalid_request mentioning "not a vector field" | vector_field_search.field points to a non-vector field | Use a field with type: "vector". Check the field definition in the Management API. |
422 validation_error mentioning vector_field_search and vector_search | Both are provided in the same request | Use one or the other — they are mutually exclusive. |
Need a refresher on the full _search payload? See the Search documentation for a complete reference.