3

I'm using jQuery ajax POST calls to query against my search index. That is working. I tried to add SortList following the documented model here which is basically adding the following to my query payload

'SortList' : {
  'results' : [
    {'Property':'RefinableDecimal00','Direction': '0'},
    {'Property':'Filename','Direction': '0'}
  ]
}

Bonus question The documentation doesn't say whether 0 is ascending or descending. I assume descending, but not sure. Anybody?

When I add that my query gives me 400 Bad Request Invalid parameter: SortList error.

Any idea how to sort search results from REST api?

  • have you tried running it through the SearchQueryTool? sp2013searchtool.codeplex.com – Eric Alexander Jul 13 '16 at 18:23
  • Looks like that doesn't run client side and we have managed workstations so I don't think I can install it. But thanks. – Rothrock Jul 13 '16 at 18:33
2

I found a tutorial yesterday that had one sort term in the post query. It took a bit of work to figure out how to do multiple terms. Here is what ended up working for me:

'SortList' : {
  'results' : [
    {'__metadata':{'type':'Microsoft.SharePoint.Client.Search.Query.Sort'},
        'Property':RefinableDecimal00,'Direction':0
    },
    {'__metadata':{'type':'Microsoft.SharePoint.Client.Search.Query.Sort'},
    'Property':FileName,'Direction':0
    }
  ]
}

BTW 0 = ascending and 1 = descending

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.