apache/beam · error · ValueError

Vector and keyword search parameters must be provided for hy

Error message

Vector and keyword search parameters must be provided for hybrid search

What it means

HybridSearchParameters combines a vector search strategy and a keyword (sparse/BM25) search strategy; hybrid search in Milvus requires both. __post_init__ raises ValueError if either `vector` or `keyword` is missing/None.

Source

Thrown at sdks/python/apache_beam/ml/rag/enrichment/milvus_search.py:199

  Args:
    vector: Parameters for the vector search component.
    keyword: Parameters for the keyword search component.
    ranker: Ranker for combining vector and keyword search results.
      Example: RRFRanker(k=100).
    limit: Maximum number of results to return per query. Defaults to 3 search
      results.
    kwargs: Optional keyword arguments for additional hybrid search parameters.
      Enables forward compatibility.
  """
  vector: VectorSearchParameters
  keyword: KeywordSearchParameters
  ranker: MilvusBaseRanker
  limit: int = 3
  kwargs: dict[str, Any] = field(default_factory=dict)

  def __post_init__(self):
    if not self.vector or not self.keyword:
      raise ValueError(
          "Vector and keyword search parameters must be provided for "
          "hybrid search")

    if not self.ranker:
      raise ValueError("Ranker must be provided for hybrid search")

    if self.limit <= 0:
      raise ValueError(f"Search limit must be positive, got {self.limit}")


SearchStrategyType = Union[VectorSearchParameters,
                           KeywordSearchParameters,
                           HybridSearchParameters]


@dataclass
class MilvusSearchParameters:
  """Parameters configuring Milvus search operations.

View on GitHub (pinned to 12126d8942)

Solutions

  1. Pass both `vector=VectorSearchParameters(...)` and `keyword=KeywordSearchParameters(...)`.
  2. If you only need one mode, use VectorSearchParameters or KeywordSearchParameters directly instead of HybridSearchParameters.
  3. Validate the search config before constructing HybridSearchParameters.

Example fix

// before
params = HybridSearchParameters(vector=VectorSearchParameters(...), ranker=RRFRanker())
// after
params = HybridSearchParameters(
    vector=VectorSearchParameters(...),
    keyword=KeywordSearchParameters(...),
    ranker=RRFRanker())
Defensive patterns

Strategy: validation

Validate before calling

if mode == 'hybrid' and not (cfg.get('vector') and cfg.get('keyword')):
    raise ValueError('hybrid search requires both vector and keyword params')

Try / catch

try:
    params = HybridSearchParameters(**cfg)
except ValueError as e:
    if 'Vector and keyword' in str(e):
        logging.error('Incomplete hybrid search config: %s', e)
    raise

Prevention

When it happens

Trigger: Constructing HybridSearchParameters(vector=VectorSearchParameters(...)) without `keyword`, or vice versa, when configuring hybrid retrieval in a RAG pipeline.

Common situations: Gradually migrating from pure vector search to hybrid and only setting half the fields; assuming keyword defaults exist (it has no default provider).

Understand the failure class

Background: "missing required argument" and "the following required arguments were not provided": what required-argument errors mean and how to fix them — this error's family across 20 libraries.

Related errors


AI-assisted analysis of apache/beam@12126d8942 (2026-09-13). Data as JSON: /api/errors/9fa22404de477d00. Report an issue: GitHub.