feat:增加Elasticsearch功能
This commit is contained in:
53
schemas/blog_elastic.py
Normal file
53
schemas/blog_elastic.py
Normal 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"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user