gpt4 book ai didi

Django Haystack - 如何提升一个领域?

转载 作者:行者123 更新时间:2023-12-04 14:49:53 26 4
gpt4 key购买 nike

我在 Django Haystack 1.2.5 中遇到了一些问题。我需要提升一个领域,但显然它不起作用。我正在使用 Solr 1.4.1。

我的指数:

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())

我在 job_title "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:我需要更加重视“job_title”字段。例如,如果我正在搜索“程序员”这个词,我需要首先显示“job_title”字段中“程序员”按日期排序的结果,然后显示“程序员”这个词的结果“job_description”字段。 Haystack boost 是实现这一目标的正确工具吗?

最佳答案

指定 boost=1.5在您的字段定义中是如何告诉 Haystack 在该特定字段上使用“字段增强”。从干草堆文档:

There are three types of boost:

  • Term Boost

  • Document Boost

  • Field Boost

Term boost happens at query time (when the search query is run) and is based around increasing the score is a certain word/phrase is seen.

On the other hand, document & field boosts take place at indexing time (when the document is being added to the index). Document boost causes the relevance of the entire result to go up, where field boost causes only searches within that field to do better.



您已经在代码中指定了字段提升,这将在为模型编制索引时提升字段,而不是在您进行查询时。好消息是,当对该字段进行搜索时,您指定的提升仍将使用,但将隐式应用,而不是在对 Solr 的查询中明确指定。

我认为您指定的查询不会对其应用提升,因为您尚未搜索任何字段。

关于Django Haystack - 如何提升一个领域?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/8368086/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com