TLDR version: Is there some trick to using
refinementFilters or a result set in an anonymous query to the Sharepoint Search REST API? Whenever I try, I get zero results, even though it returns all results if
refinementFilters / result set is removed.
Background: We need to modify a bunch of websites to use a new system for search functionality as the old system was decommissioned.
So, I've set up a Search Service application within our self-hosted Sharepoint 2013 Enterprise server which is indexing the required data (crawling a couple of websites and a couple of file shares in the company intranet), which works as expected.
I can use the search app's REST API from a browser and filter the search results based on content source with
refinementFilters='ContentSource:equals("whatever")', so results from one website only show up where intended.
However, the browser negotiates an auth token along with the request, and I need to call that API server-side from the webserver that's building the search pages. I really don't want to have to deal with authentication from the webserver at all since all this is only happening inside our intranet anyway.
Of course, as soon as I make the request from a proper REST client (e.g. Postman) or more importantly via cURL (PHP), obviously it's not going to work due to permissions. So I've enabled anonymous access and set up the
QueryPropertiesTemplate according to these two guides:
Which works fine, except that it returns every result from every content source. As soon as I add the
refinementFilters from earlier, I get zero results.
No error messages, just...nothing.
My gut feeling is that this is a permissions problem but I can't figure out what else to change?
I'm fairly new to Sharepoint so I've probably just missed a checkbox somewhere. I've also tried using a result source that does the filtering and setting its ID in the query, but get the exact same result.
I've checked out all the similar questions I could find here, but none of them addressed this issue.