我有以下餐厅和评论模型。我正在对 Restaurant 模型的某些字段进行全文搜索,如下面的 RestaurantIndexer 类所示。如何进行包含评论的全文搜索(即搜索返回 Restaurant 实例,查询包含在 RestaurantIndexer 中定义的一个或某些字段或 Comment 实例的评论字段中)?
*********餐厅模特***************
class Restaurant(models.Model):
name = models.CharField(max_length=100)
country=models.ForeignKey(Country)
city=models.ForeignKey(City)
street=models.CharField(max_length=100)
street_number=models.PositiveSmallIntegerField()
postal_code=models.PositiveIntegerField(blank=True,null=True)
category=models.ManyToManyField(Category, blank=True,ull=True)
slug = models.SlugField(unique=True)
*********评论型号***************
class Comment(models.Model):
user = models.ForeignKey(User)
restaurant = models.ForeignKey(Restaurant)
submit_date = models.DateTimeField(blank = True, null = False)
comment = models.TextField()
*********餐厅索引器***************
class RestaurantIndexer(Indexer):
tags = [
('name','name'),
('city','city'),
('country','country'),
('category', 'category'),
('tag','tag')
]
#how can I add Comment.comment?
space.add_index(Restaurant, RestaurantIndexer, attach_as='indexer')