Skip to main content
A hybrid query combines vector search with lexical search to achieve better relevance by leveraging both semantic similarity and keyword matching. Full-text search and vector search use different scoring mechanisms: text relevance depends on term and document frequency, while vector relevance scores derive from the configured similarity metric. Without proper normalization, one search method may dominate the results, leading to suboptimal ranking. Hybrid queries address this by combining and normalizing scores from both methods. LambdaDB supports three rescoring methods to combine results from different query types: rrf (Reciprocal Rank Fusion), mm (min-max), and l2 (l2_norm).
  • RRF combines rankings by taking the reciprocal of each result’s rank position, providing balanced weighting across different search methods.
  • MinMax normalization scales scores to a 0-1 range before combining.
  • L2 norm divides each retrieval path’s scores by their L2 norm (the square root of the sum of squared scores) before combining them.
Regardless of the rescoring method used, the final combined score is always normalized to a value between 0 and 1.

Parameters

Rescoring methods

Query object parameters

Each object within the rescoring method array contains a query-type key directly, with an optional sibling boost. For example, use { "knn": { ... }, "boost": 0.3 }; do not wrap that entry in another query property. Place the entire hybrid expression under the request body’s top-level query.
A hybrid query requires exactly two query objects. If you need to express more complex logic within either object, use a boolean query to combine multiple conditions.

Boost constraints

  • The boost parameter is only available for mm and l2 rescoring methods.
  • Set boost on both query objects or omit it from both to use equal weights.
  • The sum of all boost values must equal 1.0.
  • Each individual boost value must be between 0 and 1.

Examples

L2-norm hybrid query

This example combines:
  • A queryString query with 0.7 boost weight.
  • A knn vector query with pre-filtering and 0.3 boost weight.
  • Uses L2-norm rescoring to merge the results.

MinMax hybrid query with sparse vector

This example combines:
  • A sparseVector query with 0.6 boost weight.
  • A knn dense vector query with 0.4 boost weight.
  • Uses MinMax normalization to merge the results.

RRF hybrid query

This example uses Reciprocal Rank Fusion to balance text and vector search results.
The final returned documents may not include the requested number of documents from the knn query. This is because the scores of documents returned solely from other queries may be higher than those of the top k documents returned from the knn.