0
votes

I'm unable to restrict the sharepoint search to only retrieve folders.

I'm running rest requests to the search api

https://(sharepoint url)/ian/_api/search/query?querytext='metatest3'

This retrieves only the folder that is on this collection but when I use

https://(sharepoint url)/ian/_api/search/query?querytext='metatest3 and IsContainer:1'

This doesn't retrieve the folder and no results are found.

I'm perplexed because when the first API call is returned I have

<d:element m:type="SP.KeyValue">
    <d:Key>IsContainer</d:Key>
    <d:Value>true</d:Value>
    <d:ValueType>Edm.Boolean</d:ValueType>
</d:element>
1

1 Answers

2
votes

We can use the REST API below to search only folders.

https://(sharepoint url)/ian/_api/search/query?querytext='metatest3 contenttypeid:0x0120*'

Or

https://(sharepoint url)/ian/_api/search/query?querytext='metatest3 IsContainer:true'