Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/django/23.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Django Haystack-如何提升场地?_Django_Solr_Django Haystack_Solr Boost - Fatal编程技术网

Django Haystack-如何提升场地?

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

我在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_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文档中:

有三种类型的增压:

  • 长期激励

  • 文档增强

  • 磁场增强

术语提升发生在查询时(当搜索查询运行时),并且 在增加分数的基础上,可以看到某个单词/短语

另一方面,文档和字段的提升在索引时发生 (将文档添加到索引时)。文档增强原因 整个结果的相关性会上升,因为磁场增强会导致 只有在该字段中搜索才能做得更好

您已经在代码中指定了字段boost,它将在模型被索引时而不是在您进行查询时增强字段。好消息是,在该字段上进行搜索时,您指定的boost仍将被使用,但将被隐式应用,而不是在Solr查询中显式指定

我认为您指定的查询不会应用boost,因为您没有搜索任何字段。

我遇到了相同的问题--“schema.xml”在模型中使用“boost”参数后没有更改。作为一种解决方案,我已经开始使用Demax查询模式。像这样的东西对我很有用:

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)