Files
blog-service/schemas/blog_elastic.py

54 lines
1.2 KiB
Python

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"
}
}
}
}
}