【发布时间】:2014-06-19 18:41:09
【问题描述】:
我似乎无法在文档中找到它。我将如何设置每个索引的搜索属性的重要性级别。例如,假设我有一个带有搜索索引 NoteIndex 的模型 Note,
型号:
class Note(models.Model):
user = models.ForeignKey(User)
pub_date = models.DateTimeField()
title = models.CharField(max_length=200)
body = models.TextField()
索引:
class NoteIndex(indexes.SearchIndex, indexes.Indexable):
text = indexes.CharField(document=True, use_template=True)
body = indexes.CharFiled(model_attr = 'body')
author = indexes.CharField(model_attr='user')
pub_date = indexes.DateTimeField(model_attr='pub_date')
我将如何设置它以便我的对象以这样的方式被索引,无论查询多少次,与作者匹配的查询比与正文匹配的查询更重要(得分更高)与身体相匹配。由于 solr 正在运行 BM25f(不确定)文档相关性搜索,因此可能的解决方案似乎是在文本文档中多次添加作者。但这是一个不优雅的解决方案。
我想知道 haystack/python 是否完全解决了这个问题。
【问题讨论】:
-
在 solr 中,您可以在索引时 boos 字段,也可以在查询时提升字段:第二个选项更灵活,请参见此处的 'qf' 参数:cwiki.apache.org/confluence/display/solr/…