14 lines
379 B
Python
14 lines
379 B
Python
from elasticsearch import Elasticsearch
|
|
|
|
from schemas.blog_elastic import BLOG_MAPPING
|
|
from config.logging import logger
|
|
|
|
ES_HOSTS = ["http://localhost:9200"]
|
|
BLOG_INDEX = "blog"
|
|
|
|
es = Elasticsearch(hosts=ES_HOSTS)
|
|
|
|
if not es.indices.exists(index=BLOG_INDEX):
|
|
es.indices.create(index=BLOG_INDEX, body=BLOG_MAPPING)
|
|
logger.info(f"Elastic索引 {BLOG_INDEX} 创建成功")
|