I have a term store which has some terms "Defender", "Forward", etc. I then have a document library which uses those terms as meta data on the documents.
I want to use the sharepoint search api to retrieve any documents that have used the "Defender" meta data, like in the images below.
I have a function to grab the documents:
public getDocuments() {
axios
.get("https://bpk.sharepoint.com/_api/SEARCH DOCUMENTS VIA TERMS FROM THE TERM STORE",
{ params:{},
headers: { 'accept': 'application/json;odata=verbose' }
})
.then(response => {
this.setState({
documents: response.data.d.results
});
})
.catch(error => {
console.log(error);
});
}
Can anybody please point me in the right direction for what the search api end point should be? <3
EDIT - This is how I achieved this!:
public getDocuments() {
axios
.get("https://bpk.sharepoint.com/_api/search/query?querytext='owstaxIdPOsitionsx0020COlour:defender'&trimduplicates=true&rowsperpage=100&rowlimit=1000",
{ params:{},
headers: { 'accept': 'application/json;odata=verbose' }
})
.then(response => {
this.setState({
documents: response.data.d.query.PrimaryQueryResult.RelevantResults.Table.Rows.results
});
})
.catch(error => {
console.log(error);
});
}