1

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.

2 Answers 2

1

Unfortunately, only standard managed properties are included by default: http://mysite.sharepoint.com/sites/site1/_api/search/query?querytext='contenttype:ABC'

so we add the selectproperties parameter explicity to the query. Also, selectproperties also should be configured as managed properties with option Selectable.

So i don't think what you are trying to achieve is feasible.

1
  • Thank you for your answer, the content type is also a good approach to achieve the task Jul 16, 2018 at 9:46
0

Actually, you can, as described in How to find all managed properties of a document.

Basically, if you set your refiner option to managedproperties(filter=600/0/*) you will get all properties in the RefinementResults in the response

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.