from pymongo.operations import SearchIndexModel

def create_vector_search_index(
    collection,
    vector_field: str = "embedding",
    dimensions: int = 1536,
    similarity_metric: str = "cosine",
    index_name: str = "vector_search_index"
) -> None:

    # Define the vector search index
    vector_index = SearchIndexModel(
        definition={
            "mappings": {
                "dynamic": True,
                "fields": {
                    vector_field: {
                        "type": "knnVector",
                        "dimensions": dimensions,
                        "similarity": similarity_metric
                    }
                }
            }
        },
        name=index_name
    )

    # Create the vector search index
    collection.create_search_index(vector_index)
    print("Vector search index created successfully for collection.")