And*_*dré 6 django solr django-haystack solr-boost
我在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())
Run Code Online (Sandbox Code Playgroud)
我在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
Run Code Online (Sandbox Code Playgroud)
我正在做的查询是这样的:
sqs = SearchQuerySet().facet('zone_ad').facet('location_ad').order_by('-date_inserted')
Run Code Online (Sandbox Code Playgroud)
有人能给我一些线索,让我了解Haystack Boost的工作需求吗?
最好的祝福,
更新1:我需要更加重视"job_title"字段.例如,如果我正在搜索"程序员"这个词,我首先需要显示在"job_title"字段中按"日期"排序的"程序员"的结果,然后是"程序员"字样的结果. "job_description"字段.干草堆增压是实现这一目标的正确工具吗?
boost=1.5在字段定义中指定是如何告诉Haystack在该特定字段上使用"字段提升".从Haystack文档:
有三种类型的提升:
期限提升
文件提升
现场提升
术语提升发生在查询时(运行搜索查询时)并且基于增加分数,可以看到某个单词/短语.
另一方面,文档和字段提升发生在索引时 (将文档添加到索引时).文档提升会导致整个结果的相关性上升,其中字段提升仅导致该字段内的搜索更好.
您已在代码中指定了字段提升,这将在模型编制索引时提升字段,而不是在进行查询时.好消息是,当您在该字段上进行搜索时,仍会使用您指定的提升,但是将隐式应用,而不是在对Solr的查询中明确指定.
虽然您没有在任何字段上搜索,但我认为您指定的查询不会对其应用提升.
| 归档时间: |
|
| 查看次数: |
2371 次 |
| 最近记录: |