none
Different Results from REST API and SharePoint Search RRS feed

  • Question

  • When I do a search on SharePoint using the url http:///TS/EDMS/_api/search/query?querytext='tequila' and when I use the same url in a separate application that does the rest call (external application), I get two different sets of results. And when the use the search function in SharePoint directly, I get a different result from the api calls.

    Is there a way to narrow the search using the api REST service to a library? I would expect the same results from the api either through the web page or through an external call or through the built in search on SharePoint. Can someone please explain why there is a difference and what I need to do to fix it?

    Also, I have tried to append a library in the url as follows: http:///TS/EDMS/DAL/_api/search/query?querytext='tequila' and I get a 404 error, but if I remove the /_api/search/query?querytext='tequila' I get to the DAL library on SharePoint.

    Any help is appreciated.

    Monday, June 25, 2018 10:09 PM

All replies

  • Hi,

    Search query results count is an estimate number by default, so we always get different count when we browse search results pages.

    As a workaround, we can add more properties in the query to narrow the results.

    Regards.

    Tuesday, June 26, 2018 4:06 AM
  • Hi,

    1. When searching with Rest API in browser, the results are Security Trimmed. And when you searching with Rest API in external application, if the account is different with it in Browser, then it is expected to be different for these two search results. You should make sure the two accounts are the same so that the results would be the same based on user permission.

    2. If you are getting fewer results, this is because SharePoint skip the duplicated results, you could append trimduplicates=true in the Rest Url:

    http://sp/sites/dev/_api/search/query?querytext='test'&trimduplicates=true

    Check this for more detailed information:

    SharePoint Search Weirdness – Part 5: Search REST API Ignores Duplicates

    Thanks

    Best Regards


    Please remember to mark the replies as answers if they helped. If you have feedback for TechNet Subscriber Support, contact tnmff@microsoft.com.


    Click here to learn more. Visit the dedicated forum to share, explore and talk to experts about Microsoft Teams.

    Tuesday, June 26, 2018 6:51 AM