1
votes

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?

2
What is the value of the score?Jonathan Robbins
Have you tried different SearchKey values? Can you try to use p.Content.Contains or p.Content.Like and see whether they return different scores?Marek Musielak
The score value is changing based om the keyword search as the result item will be different but it is always the same value for all items returned: it is now 1.811966Mohammed Syam
Marek :: I tried different SearchKey and the value will be changed but still the same for all itemsMohammed Syam
Okay I tried two clauses and the score value is different now from item to another, The question now is if I want to measure the accuracy of search against one field like as example number of matches in the feild (content) Is it possible to do this using boosting? If not Is there another way of doing this?. At the end want to display percentage indicate the accuracy of a result item based on keyword search on the content field ?Mohammed Syam

2 Answers

2
votes

There is a post relating to this on the Sitecore Knowledge Base stating that Score of the hit is being multiplied by 0, therefore all results have the same score.

The post is relating the Lucene but I believe it is relevant to Solr as well.

To resolve

  1. In Sitecore navigate to the /sitecore/templates/System/Templates/Sections/Indexing section.
  2. Create a Standard Values item for this section.
  3. Enter the value 1 in the Boost Value field of the above-mentioned Standard Values item.
  4. Save, publish and re-index

As your instance of is an upgraded version 6.6, before ContentSearch existed, the Standard Value didn't exist nor created in upgrade scripts.

0
votes

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.