def METHOD_NAME(
    query: str,
    file_id: Optional[str] = None,
    es_host: str = "",
    es_port: int = "",
    es_username: str = "",
    es_password: str = "",
    es_index: str = "",
    es_chunk_size: int = 500,
    es_thread_count: int = 30,
    es_queue_size: int = 30,
    retriever_batch_size: int = 16,
    retriever_api_key: str = "",
    retriever_embed_title: bool = False,
    retriever_secret_key: str = "",
    retriever_topk: int = 30,
    rank_topk: int = 5,
):
    """
    :param query: The query
    :param file_id: The id of a file
    :param es_host: The host of es
    :param es_por: The host of es
    :param es_username: The username of es
    :param es_password: The password of es
    :param es_index: The index of es
    :param es_chunk_size: The chunk size of es
    :param es_thread_count: The thread count of es
    :param es_queue_size: The queue size of es
    :param retriever_batch_size: The batch_size of retriever
    :param retriever_api_key: The api_key of retriever
    :param retriever_embed_title: The embed_title of retriever
    :param retriever_secret_key: The secret_key of retriever
    :param retriever_topk: How many documents to return per query in  .
    :param rank_topk: The maximum number of documents to return in rank.
    """
    ranker = ErnieRanker(model_name_or_path="rocketqa-zh-dureader-cross-encoder", use_gpu=True)
    document_store = BaiduElasticsearchDocumentStore(
        embedding_dim=384,
        duplicate_documents="skip",
        host=es_host,
        port=es_port,
        username=es_username,
        password=es_password,
        index=es_index,
        similarity="dot_prod",
        vector_type="bpack_vector",
        search_fields=["content", "meta"],
        chunk_size=es_chunk_size,
        thread_count=es_thread_count,
        queue_size=es_queue_size,
    )
    retriever = EmbeddingRetriever(
        document_store=document_store,
        retriever_batch_size=retriever_batch_size,
        api_key=retriever_api_key,
        embed_title=retriever_embed_title,
        secret_key=retriever_secret_key,
    )
    if not file_id:
        query_pipeline = Pipeline()
        query_pipeline.add_node(component=retriever, name="Retriever", inputs=["Query"])
        query_pipeline.add_node(component=ranker, name="Ranker", inputs=["Retriever"])
        prediction = query_pipeline.run(
            query=query, params={"Retriever": {"top_k": retriever_topk}, "Ranker": {"top_k": rank_topk}}
        )
        return prediction
    else:
        filters = {
            "$and": {
                "id": {"$eq": file_id},
            }
        }
        query_pipeline = Pipeline()
        query_pipeline.add_node(component=retriever, name="Retriever", inputs=["Query"])
        query_pipeline.add_node(component=ranker, name="Ranker", inputs=["Retriever"])
        prediction = query_pipeline.run(
            query=query,
            params={"Retriever": {"top_k": retriever_topk, "filters": filters}, "Ranker": {"top_k": rank_topk}},
        )
        return prediction