0

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.

  • Can you add some details about the differences? Which queries produce more or less results if if there are any obvious patterns? – Mike Smith - MCT - MVP Jun 26 '18 at 0:59
1

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.

This is usually due to permissions. SharePoint search is security trimmed. Is the app account the same as the one you are browsing with?

And when the use the search function in SharePoint directly, I get a different result from the api calls.

If you are getting fewer items, it's because SharePoint search skips what it thinks are duplicates. Its definition of "duplicates" is quite broad.

Here's the fix for REST calls. (http://techtrainingnotes.blogspot.com/2018/01/sharepoint-search-weirdness-part-5.html)

&trimduplicates=true

Here are several ideas for Search Center duplicates: http://techtrainingnotes.blogspot.com/2015/04/sharepoint-2013-search-weirdness-part-1.html

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.

Don't put the path to the library in the URL, add it to the query.

/_api/search/query?querytext='tequila site:yourServer/sites/yourSite/'

or

/_api/search/query?querytext='tequila site:http://yourServer/sites/yourSite/'
  • Thank you for the answer, and thank you for the links as well. – john Jun 26 '18 at 15:03

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.