翻了下光头哥的博客介绍:
The first thing that I need, is to somehow find a generic way to indicate which model and which field or fields in it are to be indexed. I'm going to say that any model that needs indexing needs to define a searchable class attribute that lists the fields that need to be included in the index. For the Post model, these are the changes:
app/models.py: Add a __searchable__ attribute to the Post model.
class Post(db.Model):
__searchable__ = ['body']
# ...
例如 Post 数据类里增加 status = private (or public) 这个 filter:
class Post(db.Model):
__searchable__ = ['body']
status = private (or public)
# ...
然后往 Elasticsearch 增加索引数据时,只选择 status = public 类型的 post.body,该怎么定义这个数据模型呢? (意思是不能把 private 的数据添加到在 ES 里去)