简体   繁体   中英

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(); , 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? Thank you. For the record I am using solrnet package for.Net.

You can't sort facets in descending order with the old Facet API (which is what SolrNet uses). Until SolrNet supports the JSON Facet API natively you'll have to add it yourself.

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"

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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