我正在使用带有ElasticSearch的干草堆来搜索我网站上用户的文档。用户“追随”彼此,我希望我正在追随的用户的匹配文档显示在其他用户的匹配文档之前。在每个类别中,我想根据默认分数将排序留给Haystack。
class DocumentIndex(indexes.SearchIndex, indexes.Indexable):
text = indexes.CharField(document=True, use_template=True)
title = indexes.CharField(model_attr="title", boost=3.0)
follow = indexes.MultiValueField()
def search(self):
sqs = self.searchqueryset.auto_query(self.cleaned_data['q'])
friend_results = sqs.filter(friends=self.cleaned_data['username'])
other_results = sqs.exclude(friends=self.cleaned_data['username'])
#***** Can I do something like this? ****#
final_query_set = join (friend_results, other_results)
return final_query_set谢谢你的帮助。
发布于 2013-11-14 15:49:43
final_query_set = friend_results | other results我想这就是你要找的。
https://stackoverflow.com/questions/17537125
复制相似问题