I have a problem I am trying to figure out with the search API. Most of the time the file names are unique, but every once and a while there are two or more files in different libraries on the site with the same name. So in order to get the right file, we us the "path:" property in the REST call to narrow down the search to specific libraries.

However, I have noticed a problem when the library name has a space in it. If I use the "path:" property to search a library called ArchiveData (no spaces) the search works just fine and pulls back the document I need. However, if the library name is "Current Data" (with a space) then I get no files back.


https://<site>/_api/search/query?querytext = '(Document.doc)+AND+(path:https://<site>/ArchiveData/'

will return one document from this library.

This URL however doesn't return any hits:

 https://<site>/_api/search/query?querytext='(Document.doc)+AND+(path:https://<site>/Current Data/'

Doesn't work and I get no document. I have tried to escape the space with %20 in the library name with no luck. Can someone tell me how to encode the path for a library that has spaces in the name?

I also noticed in some of the libraries that we have that have dashes in the name the dash is replaced with a space, so it too fails in the "path:"


  • Try replacing space by _x0020_ ` https://<site>/_api/search/query?querytext='(Document.doc)+AND+(path:https://<site>/Current_x0020_Data/'` Jul 31, 2018 at 7:23
  • Already tried this, as well as URLEncoding the string too. No luck.
    – john
    Jul 31, 2018 at 14:31
  • Try 'path:"foo/bar/shared documents"' put the full path in quotes. Jul 31, 2018 at 21:31

2 Answers 2


We ran into similar issues after a re-provision of the search service. After spending significant time on the phone with Microsoft, we found including a non-default zone in our list of content sources was causing this issue.

Please see the following:



In our case we were attempting to use the server name we all knew, but was not the actual name of the default zone as listed in CA > System Settings > Alternate Access Mappings. Adding the default zone was not enough, we needed to remove the intranet and custom zones from the list under CA > Service Applications > Manage Service Applications > Search Service Application Name (not the proxy) > Content Sources > name (ours is Local SharePoint sites) > Start Addresses > List of URLs . After removal of all non-default zones, we ran a full crawl to resolve our particular no-search-links-with-spaces issue. I hope this helps.



Thanks to @Matthew McDermott's comment i solved the problem; So just put the path in quotes e.g. (when there are more than one path):

"xxx/_api/search/query?querytext='test+AND+(path:<pathWithoutSpace>+OR+path:\"<pathWith Space>\")'"

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.