我有用户模型和评论,我用django\u elasticsearch\u dsl来索引elasticsearch
# models.py
class Comment(models.Model):
user = models.OneToOneField(User, on_delete=models.CASCADE)
reply_type = models.JSONField(default=dict)
``` `reply_type` 内容
reply_type: {
"one": "on... ...",
"two": "tw... ..."
}
我是这样做的
documents.py
@registry.register_document
class UserDocument(Document):
email = fields.TextField()
username = fields.TextField()
first_name = fields.TextField()
...
...
...
comment = fields.NestedField(properties={
# other fields...
'some_field': fields.TextField(),
'reply_type': fields.ObjectField(),
})
class Index:
name = 'user'
settings = {
'number_of_shards': 1,
'number_of_replicas': 0
}
class Django:
model = User
问题是当我做索引的时候 `reply_type` 是空的
"reply_type": [
{ },
{ }
]
有什么建议吗?
暂无答案!
目前还没有任何答案,快来回答吧!