tags:

views:

57

answers:

2

I have a simple query to a Solr instance using SolrNet, But for some reason, the score is always 0.

I have verified :

  • have a field [SolrField("Score")] public double Score { get; set; } in my mapping class

  • have checked that the fields being searched are string instead of text.

What else could be wrong? Please help

Update:

  var results = solr.Query(q,
                                   new QueryOptions
                                    {
                                        OrderBy = new[] { new SolrNet.SortOrder("DateSubmitted", Order.ASC) },
                                        Fields = new[] { "score" }

                                    }
                                  );
A: 

Make sure that score is in the list of fields when you do the request (the fl parameter) because the score is not returned by default.

Pascal Dimassimo
Thanks is thsi construct (see above) sufficient? I tried this and still don't get a score.
Mikos
I would first check directly with the Solr console if making a request with the fl param set to score returns documents correctly. Then I would check if the param is correctly sent to Solr with an http request analyzer (tcpmon or fiddler).
Pascal Dimassimo
@Pascal - thanks. will try your suggestions.
Mikos
Thanks, very helpful. Figured it out.
Mikos
+1  A: 

Just like Pascal noted, the score is not returned by default, so you have to do fl=*,score to get everything and the score. In SolrNet this translates to Fields = new[] {"*","score"}.

Also mapping is case sensitive so you'll want [SolrField("score")] instead of [SolrField("Score")]

Mauricio Scheffer