0

I am trying to receive items via the SharePoint 2016 REST Search API, which works pretty good. However as I have some people with the permissions to view unpublished items or items which have expired, the API returns more elements for them, which is correct but I do not want these items to be shown. Is it possible to add a $filter criteria to my query or to select these out-of-the-box-fields?

My query looks similar to this: _api/search/query?querytext='(contenttype:MyNewsContentType)'&selectproperties='Title,Body,Date'

Edit: I can not switch to the list apis, as I need to aggregate data from a lot of sites (>50).

Thanks in advance.

2

These issues indicate that you are using highly privileged account as Search default contect access account (for example application pool account). You should change it to specially designated account with less privileges (ideally this account should have only read permissions).

More info

  • Sorry, I think I did not explain the situation good enough. The search account is configured exactly as you stated. The issue is that I am building a "news hub" which should aggregate all news from different publishing sites. However some news may not be published yet. The search displays them for me as an admin, which is totally correct (technically). From a business-use-case perspective I just want to see news that are published and valid. – kekub Feb 22 '17 at 21:44
  • 1
    since you're using the Search REST api it really should only be returning items that are published and not just in draft mode. However, if an already published article is back in draft mode, search will still surface the last published version in search. Is this not the behavior you are seeing? – David Hartman Feb 23 '17 at 3:32
  • Hi Pawel, thank you very much. I marked your reply as the correct one, as you were the first one to reply. As I said our search account was setup correctly. However a company that developed the sites in question set the document libraries versioning settings to allow anyone to see drafts. After changing this everything works just as you described. Thanks a lot! – kekub Feb 26 '17 at 10:53
2

Check the search crawler account permission level.It should be Read if you want to get only published and approved content.Any other permission level like contribute can change this behaviour

  • Hi rjv91, thank you very much for your support. The versioning-settings in the pages library allowed anyone to read drafts. – kekub Feb 26 '17 at 10:54

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.