{"record":{"id":"2d4dfee075ea7f68","repo":"apache/beam","slug":"search-strategy-must-be-provided","errorCode":null,"errorMessage":"Search strategy must be provided","messagePattern":"Search strategy must be provided","errorType":"validation","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"sdks/python/apache_beam/ml/rag/enrichment/milvus_search.py","lineNumber":246,"sourceCode":"      only primary fields including distances will be returned.\n    timeout: Search operation timeout in seconds. If not specified, the client's\n      default timeout is used.\n    round_decimal: Number of decimal places for distance/similarity scores.\n      Defaults to -1 means no rounding.\n  \"\"\"\n  collection_name: str\n  search_strategy: SearchStrategyType\n  partition_names: list[str] = field(default_factory=list)\n  output_fields: list[str] = field(default_factory=list)\n  timeout: Optional[float] = None\n  round_decimal: int = -1\n\n  def __post_init__(self):\n    if not self.collection_name:\n      raise ValueError(\"Collection name must be provided\")\n\n    if not self.search_strategy:\n      raise ValueError(\"Search strategy must be provided\")\n\n\n@dataclass\nclass MilvusCollectionLoadParameters:\n  \"\"\"Parameters that control how Milvus loads a collection into memory.\n\n  This class provides fine-grained control over collection loading, which is\n  particularly important in resource-constrained environments. Proper\n  configuration can significantly reduce memory usage and improve query\n  performance by loading only necessary data.\n\n  Args:\n    refresh: If True, forces a reload of the collection even if already loaded.\n      Ensures the most up-to-date data is in memory.\n    resource_groups: List of resource groups to load the collection into. Can be\n      used for load balancing across multiple query nodes.\n    load_fields: Specify which fields to load into memory. Loading only\n      necessary fields reduces memory usage. If empty, all fields loaded.","sourceCodeStart":228,"sourceCodeEnd":264,"githubUrl":"https://github.com/apache/beam/blob/12126d8942aaf848030c478b4c6a28c6af861c66/sdks/python/apache_beam/ml/rag/enrichment/milvus_search.py#L228-L264","documentation":"MilvusSearchParameters is a dataclass whose __post_init__ validates that required fields are set. This error means a MilvusEnricher search configuration was constructed without a search_strategy, so the enricher cannot know whether to run vector, keyword, or hybrid search against the Milvus collection.","triggerScenarios":"Constructing MilvusSearchParameters (directly or via MilvusEnricher config) with search_strategy omitted or explicitly set to None/empty while collection_name is valid.","commonSituations":"Copying a config dict and dropping the strategy key; building parameters programmatically from YAML/JSON where the field was absent; refactors that renamed the field so the old keyword is silently swallowed into **kwargs.","solutions":["Pass search_strategy=VectorSearchStrategy(), KeywordSearchStrategy(), or HybridSearchStrategy() when constructing MilvusSearchParameters","Check the config file/dict actually contains the search_strategy key","Verify no rename/typo in the keyword (it is exactly search_strategy)"],"exampleFix":"// before\nparams = MilvusSearchParameters(collection_name='docs')\n// after\nparams = MilvusSearchParameters(\n    collection_name='docs',\n    search_strategy=VectorSearchStrategy(embedding_fn=my_embedder))","handlingStrategy":"validation","validationCode":"if not params.search_strategy:\n    raise ValueError('search_strategy required before MilvusEnricher use')","typeGuard":"def has_strategy(p) -> bool:\n    return getattr(p, 'search_strategy', None) is not None","tryCatchPattern":"try:\n    enricher = MilvusEnricher(params)\nexcept ValueError as e:\n    if 'Search strategy' in str(e): params.search_strategy = VectorSearchStrategy(embedding_fn=fn)\n    else: raise","preventionTips":["Always construct MilvusSearchParameters with both collection_name and search_strategy","Centralize config building in one factory function","Validate config dicts before dataclass construction"],"tags":["python","apache-beam","milvus","rag","validation"],"backgroundTag":"missing-required-argument","analyzedSha":"12126d8942aaf848030c478b4c6a28c6af861c66","analyzedAt":"2026-09-13T01:50:10.254Z","contentChangedAt":"2026-09-13T01:50:10.254Z","schemaVersion":2},"datasetVersion":"2026-09-14T16:17:12.679Z"}