简体   繁体   English

对 solr 查询的结果进行排序

[英]Sorting the results from solr query

Hello I am trying to simply sort the results of my query alphabetically.您好,我正在尝试按字母顺序对查询结果进行简单排序。 The data that is returned looks like this:返回的数据如下所示:

"FacetFilters": [
                    {
                        "Id": 0,
                        "Name": "small",
                        "ResultCount": 47,
                        "IsSelected": false,
                        "Hide": false
                    },
                    {
                        "Id": 0,
                        "Name": "n/a",
                        "ResultCount": 1,
                        "IsSelected": false,
                        "Hide": false
                    },
                    {
                        "Id": 0,
                        "Name": "medium",
                        "ResultCount": 79,
                        "IsSelected": false,
                        "Hide": false
                    },
                    {
                        "Id": 0,
                        "Name": "large",
                        "ResultCount": 4,
                        "IsSelected": false,
                        "Hide": false
                    }
                ]

I was able to this issue post-query by reversing the list using: FacetFilters.Reverse();我可以通过使用以下方式反转列表来解决这个问题: FacetFilters.Reverse(); , but I would prefer to just get the results in the correct order through the query. ,但我更愿意通过查询以正确的顺序获取结果。 Could someone please tell me what the best way is to go about this?有人可以告诉我 go 的最佳方法是什么吗? Thank you.谢谢你。 For the record I am using solrnet package for.Net.作为记录,我正在使用 solrnet package for.Net。

You can't sort facets in descending order with the old Facet API (which is what SolrNet uses).您不能使用旧的 Facet API(这是 SolrNet 使用的)按降序对构面进行排序。 Until SolrNet supports the JSON Facet API natively you'll have to add it yourself.在 SolrNet 原生支持 JSON Facet API 之前,您必须自己添加它。

See How to implement JSON facet API in SolrNet for how to do the first part, then see Order Facet Fields by Descending Value for how to sort a facet in descending order by using the JSON facet API instead. See How to implement JSON facet API in SolrNet for how to do the first part, then see Order Facet Fields by Descending Value for how to sort a facet in descending order by using the JSON facet API instead.

"sort":"index desc"

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM