def test_max_marginal_relevance_search_errors(
        self, sync_client: Elasticsearch, index: str
    ) -> None:
        """Test max marginal relevance search error conditions."""
        texts = ["foo", "bar", "baz"]
        vector_field = "vector_field"
        embedding_service = ConsistentFakeEmbeddings()
        store = VectorStore(
            index=index,
            retrieval_strategy=DenseVectorScriptScoreStrategy(),
            embedding_service=embedding_service,
            client=sync_client,
        )
        store.add_texts(texts)

        # search without query embeddings vector or query
        with pytest.raises(
            ValueError, match="specify either query or query_embedding to search"
        ):
            store.max_marginal_relevance_search(
                vector_field=vector_field,
                k=3,
                num_candidates=3,
            )

        # search without service
        no_service_store = VectorStore(
            index=index,
            retrieval_strategy=DenseVectorScriptScoreStrategy(),
            client=sync_client,
        )
        with pytest.raises(
            ValueError, match="specify embedding_service to search with query"
        ):
            no_service_store.max_marginal_relevance_search(
                query=texts[0],
                vector_field=vector_field,
                k=3,
                num_candidates=3,
            )
Test max marginal relevance search error conditions.
test_elasticsearch/test_server/test_vectorstore/test_vectorstore.py