I am currently using the SharePoint search rest api to get the search result. Below is the code I am using
var url="http://mysite.sharepoint.com/sites/site1/_api/search/query?querytext='SearchTerm+AND+ListId:718158df-a888-434d-86f7-207aeb361989+AND+IsDocument=True'&selectproperties='Path,Author,Title,PartyInfo'";
$.ajax({
url: url,
type: "GET",
headers: {
"accept": "application/json;odata=verbose",
},
success: function (data) {
var totalLen = data.d.query.PrimaryQueryResult.RelevantResults.RowCount;
console.log("Total Data: "+ totalLen);
for(var i=0;i<totalLen;i++)
{
var docTitle = data.d.query.PrimaryQueryResult.RelevantResults.Table.Rows.results[i].Cells.results[4].Value;
var author = data.d.query.PrimaryQueryResult.RelevantResults.Table.Rows.results[i].Cells.results[3].Value;
var path = data.d.query.PrimaryQueryResult.RelevantResults.Table.Rows.results[i].Cells.results[2].Value;
var partyInfo = data.d.query.PrimaryQueryResult.RelevantResults.Table.Rows.results[i].Cells.results[7].Value;
console.log("Title: "+ docTitle);
console.log("Author: "+ author);
console.log("Path: "+ path);
console.log("Party Info: "+ partyInfo);
}
},
error: function (error) {
alert(JSON.stringify(error));
}
});
where PartyInfo is the name of the custom column in a document library whose ID I have passed in the URL (to limit the result for testing purpose only) and also the name of the managed property. The above code is working fine and I am able to get the value of my custom column through managed property name by defining it in selectproperties
tag in the URL.
My question is how can I get the value of all the managed properties associated with the current item without passing their name in selectproperties
tag. My requirement is to make a global search page across a site collection where there will be many subsites and lists. So it will not be possible to know the name of the custom column everytime.
So something like selectproperties='*'
will do the trick for me.
Any help will be appreciated.