I have added to the HelloWorld web part starting example to include a search, and I have successfully limited it to my site instead of the entire tenant.
const here = this.context.pageContext.web.absoluteUrl;
this.context.spHttpClient.get(`${here}/_api/search/query?querytext='${toSearchFor} IsDocument:true Site:${here}'
&expand=Files/ListItemAllFields
&rowLimit=20`,
SPHttpClient.configurations.v1,
{
headers: [
['accept', 'application/json;odata=verbose'],
['odata-version', '']
]
})
.then((res: SPHttpClientResponse): Promise<{}> => {
return res.json();
})
This works and only searches my site. Now I'm trying to limit it further by setting the path to a folder 'Documentation' inside of Shared Documents.
const searchTarget = "https://my.sharepoint.com/sites/name/Shared%20Documents/Documentaion";
this.context.spHttpClient.get(`${here}/_api/search/query?querytext='${toSearchFor} IsDocument:true Site:${searchTarget}'
also tried
searchTarget = "https://my.sharepoint.com/sites/name/Shared Documents/Documentaion";
searchTarget = "https://my.sharepoint.com/sites/name/Shared\ Documents/Documentaion";
searchTarget = "(https://my.sharepoint.com/sites/name/Shared Documents/Documentaion)";
searchTarget = "https://my.sharepoint.com/sites/name/Shared%20Documents/Documentaion";
searchTarget = "https://my.sharepoint.com/sites/name/Shared+Documents/Documentaion";
But anything other than 'this.context.pageContext.web.absoluteUrl' returns 0 results.