2

I have a Search Results web part which shows items from my custom list. The custom list contains a site column called Idea Date.

I've been trying for days to get this Search Results web part to sort by Idea Date (a managed property), but it just doesn't work.

Does anyone have any suggestions? Any insight into what could be going wrong?

3 Answers 3

3

If you want to avoid creating a result source every time you need a new sort criterion, here's the key:

SharePoint uses the following priority when deciding how to sort:

  1. Query rules
  2. Result source configuration (your solution above)
  3. Available sorts in the web part (This is the JSON sorting in the web part's Settings)
  4. Sorting order set on the query builder (what you tried to do originally)

So SharePoint looks at the JSON sorting first, and will ignore the sort you specify in the query builder if it sees any sorting criteria in the JSON code. Expand the Settings in your Search Result web part, click Show Sort Dropdown (just for now), and blank out everything in the JSON except for this:

[{}]

This will cause the web part to see valid JSON, but no sorts in it, so it won't interfere with what you've put into the query builder. (Note that you can't just remove all JSON code from the sort box, since hitting Apply on the web part pane will just put the default JSON right back in.) Uncheck Show Sort Dropdown again and it'll keep the JSON but hide the dropdown.

Hope this helps!

1

You can look at this post below, demonstrating how to custom sort your results using display templates. The managed property must also be sortable. http://www.eliostruyf.com/add-sorting-display-templates/

8
  • I don't want to add a sorting feature (drop down menu etc) to the display template, I just want the results to be sorted when the page loads. My managed property is sortable. I also tried mapping the crawled property to RefineableDate00, but that didn't work either.
    – matt
    Commented Feb 28, 2015 at 18:31
  • Could be something with the crawled property that is mapped to Idea Date managed property. Since managed properties cannot have spaces in their names what exactly is the name of the managed property you are using? If this is a site column then this must be a auto-generated managed property I assume. If it is auto-generated then the managed property type is TEXT. Sorting on TEXT will not give you the same sorting results you would get if you are sorting on a date. Make sure the managed property is date. Next SharePoint creates 2 crawled properties. OWS_q_Date_IdeaDate and OWS_IdeaDate. Commented Feb 28, 2015 at 23:59
  • Make sure the OWS_IdeaDate is only mapped to your DATE managed property. The OWS_q_Date_IdeaDate is a TEXT crawled property and will not give you the sorting behavior you desire. Once you have done this you must do a full crawl. This now should give you the desired sorting behavior. You can read more about this behavior here: sharepointfieldnotes.blogspot.com/2013/05/… Commented Mar 1, 2015 at 0:03
  • Still not working for me. I've mapped ows_IdeaLink_x0020_Date to RefinableDate01, and removed the crawled properties that were automatically mapped to IdeaLinkDateOWSDATE. Any other ideas?
    – matt
    Commented Mar 2, 2015 at 19:14
  • Did you do a full crawl? Commented Mar 3, 2015 at 2:15
0

There's a simple way to sort your list based on specific managed properties.

Edit the Search Result web part, under setting, you can turn on "Show sort dropdown"

Then modify the JSON directly there.

enter image description here

Then you should be able to see the result below:

enter image description here

BTW it's easier for me to use the Code Beautify to edit the JSON format.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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