0

I'm using boosting item for solr seach in sitecore 7.2. I added value in Boost Value then rebuild index so how can i sorting for result item by boosting value? I tried st like that :

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

Marek Musielak
  • 26,832
  • 8
  • 72
  • 80

1 Answers1

2

When using Sitecore with SOLR it appears that index time boosting does not work because Sitecore writes the queries using the standard query parameter. For the query to use the boost given to the item at index time it needs to use a DISMAX or EDISMAX query. Currently the Sitecore API is not setup to do that.

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. If not, you should use the .Score value of the Hits list.

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.

Richard Seal
  • 4,248
  • 14
  • 29
  • So Boost Value field in sitecore item isn't used any where in solr seach ? – Cuong Nguyen Jan 21 '16 at 02:29
  • I believe it may be used when the data is crawled and indexed. But because Sitecore uses the standard query and not `DISMAX` or `EDISMAX` queries, the boost value is not used. See this for more information: https://wiki.apache.org/solr/SolrRelevancyFAQ – Richard Seal Jan 21 '16 at 02:52