def METHOD_NAME(index_name, doc_dir):
    if args.search_engine == "milvus":
        document_store = MilvusDocumentStore(
            embedding_dim=args.embedding_dim,
            host=args.host,
            index=args.index_name,
            port=args.port,
            index_param={"M": 16, "efConstruction": 50},
            index_type="HNSW",
        )
    else:
        launch_es()
        document_store = ElasticsearchDocumentStore(
            host=args.host,
            port=args.port,
            username="",
            password="",
            embedding_dim=args.embedding_dim,
            index=index_name,
        )
    if args.embedding_type == "image":
        docs = [
            Document(content=f"./{args.doc_dir}/{filename}", content_type="image")
            for filename in os.listdir(args.doc_dir)
        ]
    elif args.embedding_type == "text":
        docs = convert_files_to_dicts(dir_path=args.doc_dir, split_paragraphs=True, encoding="utf-8")
    else:
        raise NotImplementedError
    print(docs[:3])
    # 文档数据写入数据库
    document_store.write_documents(docs)
    if args.embedding_type == "image":
        # 文搜图，对image做embedding
        retriever_mm = MultiModalRetriever(
            document_store=document_store,
            query_embedding_model=args.query_embedding_model,
            query_type="text",
            document_embedding_models={"image": args.document_embedding_model},
        )
    else:
        # 图搜文，对text做embedding
        retriever_mm = MultiModalRetriever(
            document_store=document_store,
            query_embedding_model=args.query_embedding_model,
            query_type="image",
            document_embedding_models={"text": args.document_embedding_model},
        )
    # 建立索引库
    document_store.update_embeddings(retriever_mm)