I am trying to use REST to return items from a list, the search query needs to be filtered by Managed Properties, by Path and by type to ensure only List Items are returned.
The Managed Property values are dynamic, and sometimes null. This means I can't include them in a Search Scope I think. I have looked into the documentation for a POST request to the Search API but I am not quite sure how to get it working.
$.ajax({
url: url + "/_api/search/query",
method: "POST",
headers: {
"Accept": "application/json; odata=verbose",
"X-RequestDigest": $("#__REQUESTDIGEST").val(),
},
body: {
'__metadata': {
'type': 'Microsoft.Office.Server.Search.REST.SearchRequest'
},
'Querytext': 'ManagedProp:value',
'SelectProperties': {
'results': [
"mp1", "mp2", "ect"
]
},
'SourceId': 'guid' //I have put the Path and limit to STSListItem in this results sourse
},
success: function(data) {
console.log("no of items: " + data.d.query.PrimaryQueryResult.RelevantResults.Table.Rows.results.length);
//data.d.query.PrimaryQueryResult RETURNING NULL
}
});
This is what I have so far, data.d.query.PrimaryQueryResult returns null from this