Sorting solr search results using multiple fields (solrj)

橙三吉。 提交于 2019-12-03 20:58:41
javanna

If it looks like solrj is using just one of the sort fields, maybe you're using the SolrQuery#setSortField method instead of the addSortField like this:

solrQuery.addSortField("field1", ORDER.desc);
solrQuery.addSortField("field2", ORDER.desc);

In order to sort the results as you described, a cleaner solution would be adding a field to your index containing a kind of weight based on the entity type. Then you could directly sort using that field: weight desc, score desc. Before doing this, just make sure the weight has always to win against the solr score, otherwise you should work on influencing the solr score.

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