新增“数据编辑”
This commit is contained in:
@@ -1,17 +1,13 @@
|
||||
from django_elasticsearch_dsl import Document, fields, Index
|
||||
from .models import AchievementData, User, ElasticNews
|
||||
from .indexes import INDEX_NAME
|
||||
|
||||
# 获奖数据索引 - 对应Flask项目中的wordsearch266666
|
||||
ACHIEVEMENT_INDEX = Index('wordsearch266666')
|
||||
ACHIEVEMENT_INDEX = Index(INDEX_NAME)
|
||||
ACHIEVEMENT_INDEX.settings(number_of_shards=1, number_of_replicas=0)
|
||||
|
||||
# 用户数据索引 - 对应Flask项目中的users
|
||||
USER_INDEX = Index('users')
|
||||
USER_INDEX.settings(number_of_shards=1, number_of_replicas=0)
|
||||
USER_INDEX = ACHIEVEMENT_INDEX
|
||||
|
||||
|
||||
# 新闻索引 - 保留原有功能
|
||||
NEWS_INDEX = Index('elastic_news')
|
||||
NEWS_INDEX.settings(number_of_shards=1, number_of_replicas=0)
|
||||
|
||||
@ACHIEVEMENT_INDEX.doc_type
|
||||
class AchievementDocument(Document):
|
||||
@@ -41,13 +37,3 @@ class UserDocument(Document):
|
||||
model = User
|
||||
# fields列表应该只包含需要特殊处理的字段,或者可以完全省略
|
||||
# 因为我们已经显式定义了所有字段
|
||||
|
||||
@NEWS_INDEX.doc_type
|
||||
class NewsDocument(Document):
|
||||
"""新闻文档映射 - 保留原有功能"""
|
||||
id = fields.IntegerField(attr='id')
|
||||
title = fields.TextField(fields={'keyword': {'type': 'keyword'}})
|
||||
content = fields.TextField(fields={'keyword': {'type': 'keyword'}})
|
||||
|
||||
class Django:
|
||||
model = ElasticNews
|
||||
Reference in New Issue
Block a user