def test_metadata_mapping(self, sync_client: Elasticsearch, index: str) -> None:
        """Test that the metadata mapping is applied."""
        test_mappings = {
            "my_field": {"type": "keyword"},
            "another_field": {"type": "text"},
        }
        store = VectorStore(
            index=index,
            retrieval_strategy=DenseVectorStrategy(distance=DistanceMetric.COSINE),
            embedding_service=FakeEmbeddings(),
            num_dimensions=10,
            client=sync_client,
            metadata_mappings=test_mappings,
        )

        texts = ["foo", "foo", "foo"]
        metadatas = [{"my_field": str(i)} for i in range(len(texts))]
        store.add_texts(texts=texts, metadatas=metadatas)

        mapping_response = sync_client.indices.get_mapping(index=index)
        mapping_properties = mapping_response[index]["mappings"]["properties"]
        assert mapping_properties["vector_field"] == {
            "type": "dense_vector",
            "dims": 10,
            "index": True,
            "index_options": {
                "ef_construction": 100,
                "m": 16,
                "type": "int8_hnsw",
            },
            "similarity": "cosine",
        }

        assert "metadata" in mapping_properties
        for key, val in test_mappings.items():
            assert mapping_properties["metadata"]["properties"][key] == val
Test that the metadata mapping is applied.
test_elasticsearch/test_server/test_vectorstore/test_vectorstore.py