feat:增加Elasticsearch功能

This commit is contained in:
2025-09-24 20:04:23 +08:00
parent 842da15886
commit ef938e6d97
5 changed files with 105 additions and 3 deletions

53
schemas/blog_elastic.py Normal file
View File

@@ -0,0 +1,53 @@
from datetime import datetime
from typing import Optional
from pydantic import BaseModel
class BlogElastic(BaseModel):
id: int
title: str
content: str
category: str
BLOG_MAPPING = {
"mappings": {
"properties": {
"id": {"type": "integer"},
"title": {
"type": "text",
"analyzer": "ik_max_word",
"fields": {
"keyword": {"type": "keyword"}
}
},
"content": {
"type": "text",
"analyzer": "ik_max_word"
},
"category": {
"type": "keyword"
},
"createTime": {
"type": "date",
"format": "yyyy-MM-dd HH:mm:ss||epoch_millis"
},
"updateTime": {
"type": "date",
"format": "yyyy-MM-dd HH:mm:ss||epoch_millis"
}
}
},
"settings": {
"number_of_shards": 1,
"number_of_replicas": 1,
"analysis": {
"analyzer": {
"ik_max_word": {
"type": "ik_max_word"
}
}
}
}
}