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.
Reading the Response
In addition to the usual _sys/data payload, vector-enabled responses include metadata:
"metadata": {
"search_mode": "vector_boosted",
"vector_search_enabled": true,
"tokens_used": 256
}
search_modeechoes the mode Flux executed (useful if you let users choose).vector_search_enabledconfirms embeddings were used.tokens_usedapproximates the number of tokens sent to the embedding model (helpful for monitoring costs).
Best Practices
- Start with a smaller
top_k(10–25) to keep responses fast. Increase only when needed. - Tune
similarity_threshold– 0.7 is a good baseline; lower it for broader matches. - 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_searchwhen required, combiningfind_textwithsearch_mode="vector", or exceeding the join limit all return422 invalid_request. 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.
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 invalid_request mentioning vector search | Missing vector_search payload or using find_text when search_mode="vector" | Update the request to match the mode requirements. |
| 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. |
Need a refresher on the full _search payload? See the Search documentation for a complete reference.