def _mode_must_match_retrieval_strategy(
    mode: VectorStoreQueryMode, retrieval_strategy: AsyncRetrievalStrategy
) -> None:
    """
    Different retrieval strategies require different ways of indexing that must be known at the
    time of adding data. The query mode is known at query time. This function checks if the
    retrieval strategy (and way of indexing) is compatible with the query mode and raises and
    exception in the case of a mismatch.
    """
    if mode == VectorStoreQueryMode.DEFAULT:
        # it's fine to not specify an explicit other mode
        return

    mode_retrieval_dict = {
        VectorStoreQueryMode.SPARSE: AsyncSparseVectorStrategy,
        VectorStoreQueryMode.TEXT_SEARCH: AsyncBM25Strategy,
        VectorStoreQueryMode.HYBRID: AsyncDenseVectorStrategy,
    }

    required_strategy = mode_retrieval_dict.get(mode)
    if not required_strategy:
        raise NotImplementedError(f"query mode {mode} currently not supported")

    if not isinstance(retrieval_strategy, required_strategy):
        raise ValueError(
            f"query mode {mode} incompatible with retrieval strategy {type(retrieval_strategy)}, "
            f"expected {required_strategy}"
        )

    if mode == VectorStoreQueryMode.HYBRID and not retrieval_strategy.hybrid:
        raise ValueError(f"to enable hybrid mode, it must be set in retrieval strategy")

    Different retrieval strategies require different ways of indexing that must be known at the
    time of adding data. The query mode is known at query time. This function checks if the
    retrieval strategy (and way of indexing) is compatible with the query mode and raises and
    exception in the case of a mismatch.
    
llama-index-integrations/vector_stores/llama-index-vector-stores-elasticsearch/llama_index/vector_stores/elasticsearch/base.py