This week I noticed something strange when configuring a Search Results Web Part with a predefined query. The results were retrieved perfectly, but the sorting configuration was not doing what I defined. The search result web part was configured to get the documents from a specific site and sort them by the creation date.
I had configured the search query in the Query Builder of the Search Web Part to retrieve the documents (which is very easy with the query builder). Underneath the sorting tab, I configured it to sort by the creation date.
Here you can see the sorting configuration:
Storing the settings was not giving me the correct result. Whatever I configured in the sorting settings, the web part ignored the settings.
Solution: Results Source Approach
Configuring the sorting in the web part settings did not work, so the next thing I tried was to create a result source with the same query. Creating a result source can be done on the Site Collection itself, so you do not need to go to Central Administration.
Note: here you can read how to configure a custom result source.
For the result source I used the same configuration and sorting settings as in the search results web part.
The nice thing about this results sources is that they can be used in the Query Builder.
After the creation of the result source I configured the search results query builder and specified my result source as the query that needs to be used.
Note: the query text may remain empty.
This approach works perfectly, the result source does the sorting, instead of the search results web part.