Django Haystack-如何提升场地?
我在Django Haystack 1.2.5中遇到了一些问题。我需要提升一个领域,但很明显,它不起作用。我使用的是Solr1.4.1 我的索引:Django Haystack-如何提升场地?,django,solr,django-haystack,solr-boost,Django,Solr,Django Haystack,Solr Boost,我在Django Haystack 1.2.5中遇到了一些问题。我需要提升一个领域,但很明显,它不起作用。我使用的是Solr1.4.1 我的索引: class JobsTextIndex(indexes.SearchIndex): text = indexes.CharField(document=True, use_template=True) job_title = indexes.CharField(model_attr='job_titl
class JobsTextIndex(indexes.SearchIndex):
text = indexes.CharField(document=True, use_template=True)
job_title = indexes.CharField(model_attr='job_title', boost=1.50)
job_description = indexes.CharField(model_attr='job_description')
country_ad = indexes.CharField(model_attr='country_ad')
zone_ad = indexes.CharField(model_attr='zone_ad', faceted=True)
location_ad = indexes.CharField(model_attr='location_ad', faceted=True)
date_inserted = indexes.DateTimeField(model_attr='date_inserted')
def index_queryset(self):
"""Used when the entire index for model is updated."""
return JobsadsText.objects.filter(date_inserted__lte=datetime.datetime.now())
我的工作标题中有“boost=1.50”,但这显然不起作用,这是Solr产生的结果:
INFO: [core0] webapp=/solr path=/select/ params={facet=on&sort=date_inserted+desc&fl=*+score&start=0&q=arquiteto&facet.field=location_ad_exact&facet.field=zone_ad_exact&wt=json&fq=django_ct:(myapp.jobstext)&rows=20} hits=65 status=0 QTime=5
我正在做的查询是:
sqs = SearchQuerySet().facet('zone_ad').facet('location_ad').order_by('-date_inserted')
有人能给我一个线索,我需要什么让Haystack Boost工作
致以最良好的祝愿
更新1:我需要更加重视“职务”字段。例如,如果我正在搜索“程序员”一词,我首先需要在“职位”字段中按日期排序显示“程序员”的结果,然后在“职位描述”字段中显示“程序员”一词的结果。Haystack boost是实现这一目标的正确工具?在字段定义中指定
boost=1.5
是告诉Haystack在特定字段上使用“字段boost”的方式。从Haystack文档中:
有三种类型的增压:
- 长期激励
- 文档增强
- 磁场增强
SearchQuerySet().filter(text=Raw("{!dismax qf='field1^3 field2^2 text'}" + query))
我希望这会对某人有所帮助。谢谢你的回复。我重建了索引,但搜索结果与在模型中添加“boost”参数之前相同。我注意到的另一件事是,“schema.xml”在我在模型中使用了“boost”参数之后没有改变,我运行了“build\u solr\u schema”命令,但是模型上的“boost”没有任何效果。有人有更多的线索吗?谢谢。我遇到了完全相同的问题:我想提升一个场,但提升参数没有任何作用。在queryset上调用.boost()方法只会产生非常不可预测的结果。你找到解决办法了吗?@mixedCase,我还没找到办法。在我的例子中,我唯一的选择是使用“Demax”Solr功能进行原始查询,但我已经没有时间阅读更多关于Solr的内容了……有没有好的资源来阅读如何实现这一点?或者你找到了更好的解决办法?我不知道你是什么意思。我读过,也读过。我还将代码稍微更改为:
SearchQuerySet().filter(text=AltParser('demax',q,qf='field1^3 field2^2 text'))
SearchQuerySet().boost(''%s''%number,2.0)