init_elasticsearch.py 985 Bytes
Newer Older
崔为之's avatar
崔为之 committed
1 2 3 4 5 6 7 8 9
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
"""
# @Version     : Python 3.11.4
# @Software    : Sublime Text 4
# @Author      : StudentCWZ
# @Email       : StudentCWZ@outlook.com
# @Date        : 2023/10/28 18:16
# @File        : init_elasticsearch.py
崔为之's avatar
崔为之 committed
10
# @Description : Initializes the FlaskElasticsearch extension for a Flask application.
崔为之's avatar
崔为之 committed
11 12 13 14
"""


from flask import Flask
崔为之's avatar
崔为之 committed
15
from application.libs import FlaskElasticsearch
崔为之's avatar
崔为之 committed
16 17 18 19 20 21

es = FlaskElasticsearch()


def init_elasticsearch(app: Flask) -> None:
    """
崔为之's avatar
崔为之 committed
22 23 24 25 26 27 28 29 30
    Initializes the FlaskElasticsearch extension for a Flask application.

    Elasticsearch is a distributed, RESTful search and analytics engine capable of
    addressing a growing number of use cases. As the heart of the Elastic Stack,
    it centrally stores your data for lightning fast search, fine‑tuned relevancy,
    and powerful analytics that scale with ease.

    Args:
        app (Flask): The Flask application.
崔为之's avatar
崔为之 committed
31

崔为之's avatar
崔为之 committed
32 33
    Returns:
        None
崔为之's avatar
崔为之 committed
34 35
    """
    es.init_app(app)