Search code examples
solrsitecoresitecore7

Sitecore Solr Search Score Value


I am trying to get the score value for each returned result item but the problem is all items returned the same score value. I am using sitecore 7.2 site which was upgraded from sitecore 6.6. I am using solr version 4.10.2-0

The following is the code that I am using:

var contentPredicate = PredicateBuilder.True<customSearchResultItem>();
contentPredicate = contentPredicate.And(p => p.Content.Matches(SearchKey.Boost(1.0f)));

IQueryable<SearchResultItem> query = context.GetQueryable<customSearchResultItem>().Where(contentPredicate);

var hits =  query.GetResults().Hits;

foreach (var item in hits)
{
    scores.Add(item.Score);
}

Would you please advise if something is missing? or if there are any configuration that should be applied to make this work?


Solution

  • The following should be exist to apply boosting feature and sorting items accordingly:

    • The search should be with more than one clause, else the items retrived will have the same score value
    • When search contains more than clause ( predicate ) they will have the same weight on the score value unless applying the boost method ".Boost(10.0f).
    • The combination between clauses should be "OR", Else the returned items must match all predicates to be retrieved which means same score value.