简体   繁体   English

在Sitecore v7中使用Boosting Item Solr进行排序

[英]Sorting with Boosting item solr in sitecore v7

I'm using boosting item for solr seach in sitecore 7.2. 我在Sitecore 7.2中使用Boosting项目进行solr seach。 I added value in Boost Value then rebuild index so how can i sorting for result item by boosting value? 我在Boost Value中添加了值,然后重建了索引,那么如何通过Boosting Value对结果项进行排序? I tried st like that : 我尝试过这样的st:

var dataQuerycontext.GetQueryable<SearchResultItem>()
....
dataQuery = dataQuery.OrderByDescending(i => i["score"]);
var results = dataQuery.GetResults().Hits.Select(h => h.Document);

But it's not working. 但这不起作用。 Seem store always have value is 1 似乎商店的总价值是1

When using Sitecore with SOLR it appears that index time boosting does not work because Sitecore writes the queries using the standard query parameter. 将Sitecore与SOLR结合使用时,似乎无法提高索引时间,因为Sitecore使用标准查询参数编写查询。 For the query to use the boost given to the item at index time it needs to use a DISMAX or EDISMAX query. 为了使查询在索引时间使用赋予项目的提升,它需要使用DISMAXEDISMAX查询。 Currently the Sitecore API is not setup to do that. 目前尚未设置Sitecore API。

So you would have to do your boosting at query time. 因此,您将不得不在查询时进行提升。

Also, your order by on the score is not required, the results from .GetResults() should already be ordered by the score. 另外,不需要按分数排序, .GetResults()的结果应该已经按分数排序。 If not, you should use the .Score value of the Hits list. 如果不是,则应使用“ Hits列表的.Score值。

var dataQuerycontext.GetQueryable<SearchResultItem>()
    .where(x => (x.MyField == "myvalue").Boost(2f)
    ... more query options ...
    )
....
var results = dataQuery.GetResults().Hits
    .OrderByDescending(h => h.Score).Select(h => h.Document);

That will then boost the field in the query. 然后,这将提高查询中的字段。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM