Prepare your pipeline
Before tuning, confirm your pipeline follows the stage ordering requirements in Choosing, implementing, and troubleshooting NHS stages. Then apply the following guidance.- Encode the raw user query. Vectorize the original query the user typed, not an augmented version of it. Place the Vectorize Query stage as early as possible in the pipeline, before any stage that rewrites the query. If an earlier stage, such as spell correction, changes the query, save the raw query to a separate parameter first and pass that parameter into the Vectorize Query stage.
-
Fix highlighting before the NHQ stage.
Highlighting can conflict with hybrid stages, causing query failures such as
Index _ out of bounds for length _. To resolve this, sethl.qto the lexical-only query parameter (<request.params.q>) before the hybrid stage, or to<request.params.raw_lex_q>after it. -
Preserve the pre-NHQ query for boosting stages.
The NHQ stage rewrites
qfor the Solr query, so any boosting stage that runs after NHQ can’t reliably useqto reference the original query text. Before the NHQ stage fires, copyqto a separate parameter for boosting stages to reference, or use<request.params.raw_lex_q>, which the NHQ stage populates with the original query.Add a “Copy Original Query” stage at the very beginning of the pipeline to make this copy operation explicit, and use that parameter as the input for your vectorize, boost, and highlighting stages. - Move security and ACL filters into vector prefiltering. If your pipeline applies security or access-control filters, such as graph joins, site restrictions, or user-group exclusions, review where those filters run relative to vector search. Filters applied after vector retrieval let semantically similar but disallowed documents occupy the candidate pool. They’re removed from the response, but they’ve already displaced valid results. Uncheck Block pre-filtering in the NHQ stage, then follow the linked procedure to configure vector prefilters through a Graph Security Trimming or JavaScript stage after NHQ. Retain top-level security filters so access restrictions also apply to lexical matches. For implementation details, see Neural Hybrid Query stage.
-
Plan your index encoding string.
Decide what content makes up the string sent to the vectorize stage at index time, for example:
Cap the string length, for example at 10,000 characters, to keep indexing time predictable and truncation behavior consistent. Consider tracking the word count of the encoding string in a dedicated index field for monitoring and analysis.Embedding models have a fixed token limit, and content beyond that limit is silently truncated regardless of how long your encoding string is. For knowledge management use cases with long documents, passing the full document as-is means only the opening content gets semantically represented. Content deeper in the document isn’t discoverable through vector search no matter how well you tune the hybrid parameters. Chunk long content instead, or fall back to an AI-generated summary or extracted keywords as the encoding input. See Chunking.
Minimum recommended stage order
- Vectorize Query
- Query Fields
- Neural Hybrid Query
- Boost with Signals
- Apply Rules
- Solr Query
Set a baseline for evaluation
Evaluating against a golden or silver dataset with offline metrics is essential. Without it, you can’t measure whether a change improves or hurts your results. See Semantic vector search test guidelines for guidance on building a golden dataset and calculating metrics. Recommended primary metric by use case:Tune parameters step by step
Start broad, then narrow, changing one variable at a time so you can attribute changes in your offline metrics to a specific parameter.1
Set initial NHQ parameters wide open
Before running any evaluations, set:
- Number of Vector Results (
topK): 1000 or higher - Min Return Vector Similarity: 0.0 to 0.5
topK values from 1 to 1000.
To test higher values, add an Additional Query Parameters stage after the NHQ stage that replaces the vec_sim_q parameter with {!knn f=$vec_field v=$vec_q topK=$top_k preFilter=$vectorPreFilter} and sets top_k to your value.
Fusion 6 raises this limit.Tight similarity cutoffs or a low topK hide downstream tuning effects and starve boosting stages of candidates to act on.
HNSW recall is imperfect, so Solr’s implementation often needs a higher topK to ensure the best candidates are retrieved at all.An ensemble of scoring algorithms needs a good pool of candidates from each one.
Limiting topK or raising the similarity cutoff too early starves the re-ranking step of candidates before boosting or weighting ever gets a chance to act.2
Remove complexity
Turn off the Boost with Signals stage and any large filters.Boosting strongly influences result order and can mask the quality of the underlying hybrid search.
Turn it off first so you can tune the best possible NHS configuration, then re-enable boosting to add further lift.
Large or complex filters similarly make it hard to tell whether a change in results came from your hybrid tuning or the filters, so simplify until the base configuration is set.
3
Choose an embedding model
Lucidworks hosts pre-trained open-source models and supports custom trainable models, as well as Ray/Seldon deployments for client-managed models.
- Pre-trained models are the right choice for a proof of value on an expedited timeline, or when you don’t yet have enough signals to train a custom model.
snowflake-arctic-embed-m-v2.0is a good default: a solid performance/speed trade-off with multilingual support. For this model, reducing dimensions to 256 (from 768) with int8 quantization optimizes Solr storage. - Custom embedding models, trained on your own data, generally produce the highest accuracy once you have enough signals (as a rule of thumb, more than 1,000 unique queries). E-commerce datasets tend to see the largest improvement from a custom model relative to a pre-trained one.
- Client-managed (Ray/Seldon) models are supported for teams that want to deploy and manage their own model, but this path works best when you also have the data science resources to tune it.
Embedding models have a maximum token context window, and content beyond that limit is truncated before vectorization.
Lucidworks pre-trained models are currently limited to 512 tokens, roughly 2,000 characters.
Separately, the vectorization API rejects a raw input payload larger than 1 MB.
If document body size is variable, cap your encoding string at a reasonable character limit, for example 20,000 characters, to avoid payload errors and keep truncation predictable.
4
Tune the squash factor
With a model selected and vectors indexed, run your first round of evaluations varying only the squash factor in the NHQ stage, with boosting still disabled.
Run at least 5 iterations, then select the best-performing value before moving on.Suggested starting values: 0.001, 0.01, 0.05How squash works: the NHQ stage compresses the raw lexical (BM25) score into a comparable range using:The
tanh function produces an S-shaped curve: it rises steeply near zero, passes through a roughly linear “sweet spot,” then flattens asymptotically toward 1.0 as inputs grow large.
The squash factor (α) controls how quickly the curve rises, and therefore which range of BM25 scores falls in the useful, linear portion of the curve.The question to ask when choosing α is where your relevant documents’ BM25 scores typically fall.
You want that range to land in the rising, non-saturated part of the curve, where score differences between documents survive squashing.
If those scores fall in the flat region instead, they collapse to nearly the same value and the lexical ranking signal is lost.5
Tune lexical and vector weights
Keep your squash factor fixed while you test weight combinations.
Vector and lexical weights should add up to 1.Starting values to test:
Don’t let a preferred weight combination, whether from experience or a stakeholder request, stop you from testing the full range.
The goal is the best-performing setup, not the most familiar one.
Production e-commerce deployments with a strong vector model have landed on weight combinations as lopsided as 0.99 vector to 0.01 lexical, which can look counterintuitive until your evaluation metrics back it up.
6
Tune boosting scale
With squash and weights fixed, enable your boosting stage.
Run a baseline with boost scaling disabled, then test the Boost with Signals stage’s Scale Boosts setting with the following ranges.Starting values to test:
If scaling has little effect on your metrics, a minimum of 0.01 and a maximum of 0.9 is a reasonable default.
This keeps scores within the 0 to 0.9 range, which aligns with Solr’s hybrid scoring.
7
Tune topK
Keep boosting enabled and adjust Number of Vector Results (
topK).
Smaller values keep response time predictable, but Solr’s HNSW implementation hardcodes efSearch to topK × 2, which has a large influence on recall quality.
As a result, a higher topK sometimes improves recall enough to be worth the added latency.Starting values to test: 200, 500, 1000, and, if you use the top_k override described earlier, 2000 and 5000The actual number of vector candidates retrieved is
topK × shard count.
A single shard is common in e-commerce deployments, but enterprise document repositories often use multiple shards.
In a multi-shard environment, a topK of 200 across 5 shards yields up to 1,000 candidates before re-ranking.
Factor this into your latency expectations.8
Tune the cosine similarity cutoff
Keep boosting enabled and set Min Return Vector Similarity, which filters out document similarities below a score threshold rather than limiting by
topK.
This parameter isn’t strictly necessary, because leaving it low allows full recall of the topK candidates.
However, it can reduce irrelevant results in the candidate pool, improve offline metrics, and make relevancy more consistent when filters are applied to results beyond the first page.
Setting it too high can return null or zero results, so validate against your evaluation set as you raise it.Starting values to test: 0.5, 0.6, 0.7, 0.8Backfill embeddings on existing collections
When you enable NHS on an existing Solr collection, documents indexed before NHS was implemented won’t have vector fields and won’t participate in vector search, which can produce inconsistent hybrid results.-
Configure a datasource that queries for documents missing an embedding.
Solr doesn’t support existence queries (
field:*) on vector field types, so use the boolean field the indexing vectorization stage writes whenever it successfully adds an embedding (<vector_field_name>_b) for existence filtering instead:Match<source_content_field>to whichever fields your pipeline uses to build the encoding string. - Feed the results through your index pipeline’s embedding stages using a partial update pipeline, which writes only the embedding-related fields and doesn’t overwrite other document data.
-
Set
rejectUpdatesIfDocNotPresent=trueon the partial update stage so the backfill job only modifies documents that already exist in the collection, which prevents accidentally creating incomplete records if a document was deleted between query time and update time. - Monitor backfill progress by querying for remaining documents where the boolean presence field is absent.
Documents without embeddings continue to return lexical-only results until they’re backfilled.
You don’t need to pause production traffic during backfill, because the pipeline serves the best available result type per document.
Verify production readiness
Before promoting an NHS-enabled pipeline to production, review every stage for logging or diagnostic behavior intended for development use. Verbose logging under production query load can cause log noise and performance degradation, and stages that append diagnostic data to query responses can expose internal pipeline state to API consumers. Disable or remove these stages before go-live. Also confirm:- The query profile routes to the correct pipeline.
- Solr configs are enriched with the vector field definitions and parsers your pipeline expects.
- The Lucidworks AI gateway production account is configured and enabled for relevant users.
- Every datasource feeding the collection uses the NHS-enabled index pipeline, if applicable.
- Embedding coverage is verified. If needed, run a backfill first.
- Hybrid search parameters are tested under production-scale query load.
- Security/ACL filter migration to vector prefiltering is tested with production ACL data.
- Signals boost ranges are recalibrated for the hybrid score scale, if signals boosting is in use.
- A rollback plan is confirmed: know which query profile change reverts to the legacy lexical pipeline.