Thursday, 23 March 2017

Author(Created By) Managed Property having more than one user in Odata search results SharePoint 2013

Hi All,
 
In our project we faced an issue in search query. Our requirement is to show all the requests raised by the current user in a page. So Basically we need to use "Created By" field in Search Rest end point url. Initially we used the following Rest end point url to retrieve the requests.
 
<Site_URL>/_api/search/query?querytext='Author:"<Current User Login Name>"
 
Please Note that we have used the managed property "Author" as it is the internal name of "Created By". 
Later we got an issue that more than one user was able to see the same request . Logically "created by" will be only one user. The issue is because "Author" property has the user who created the item and also the user who last modified the item. So the item was visible for both creator and last modified user.
 
For this we found an other managed property AuthorOWSUSER which resolved our issue.
 
So the final rest end point url is
 
<Site_URL>/_api/search/query?querytext='AuthorOWSUSER:"<Current User Login Name>"

Thank You 
Happy Coding ☺

No comments:

Post a Comment