def year_indexed(collection: Collection) -> str:
    """
    Search Index on metadata.year nested field of type number.

    This is required to do filtered vector search.
    """
    if not any(
        idx["name"] == "metadata_year" for idx in collection.list_search_indexes()
    ):
        index.create_fulltext_search_index(
            collection=collection,
            index_name="metadata_year",
            field="metadata.year",
            field_type="number",
            wait_until_complete=TIMEOUT,
        )
        assert any(
            idx["name"] == "metadata_year" for idx in collection.list_search_indexes()
        )

    return FILTER_INDEX_NAME

    Search Index on metadata.year nested field of type number.

    This is required to do filtered vector search.
    
llama-index-integrations/vector_stores/llama-index-vector-stores-mongodb/tests/test_filters.py