SolrNet - Score always 0

删除回忆录丶 提交于 2019-12-06 12:34:16

问题


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" }

                                    }
                                  );

回答1:


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.




回答2:


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")]



来源:https://stackoverflow.com/questions/3709541/solrnet-score-always-0

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!