Share via

SharePoint REST search: Too many fields are returned of each result even though SelectProperties is set

davidelsner 76 Reputation points
2022-06-16T15:28:43.573+00:00

I would like to improve the performance of my app and noticed that if I use the SharePoint REST API, many properties are included in my search results that I do not need and did not request.

My request body looks like this - I am trying to limit the returned fields with the "selectProperties" option:

{  
    "request": {  
        "Querytext": "HFCustomer: DemoCustomer docid>1068007945298532582",  
        "SortList": [  
                {  
                    "Property": "docid",  
                    "Direction": 0  
                }  
            ],          
        "Properties": [  
  
        ],  
        "SelectProperties": [  
            "DocId",  
            "Title",  
            "Path",  
            "Author",  
            "Size",  
            "LastModifiedTime"                 
        ],  
        "RowLimit": 10,  
        "ClientType": "ContentSearchRegular",  
        "TrimDuplicates": true  
    }  
}  

But still each result includes the following segments that are not needed for my app:

{
"__metadata": {
"type": "SP.KeyValue"
},
"Key": "ResultTypeIdList",
"Value": "0",
"ValueType": "Edm.String"
},
{
"__metadata": {
"type": "SP.KeyValue"
},
"Key": "ResultTypeId",
"Value": "0",
"ValueType": "Edm.String"
},
{
"__metadata": {
"type": "SP.KeyValue"
},
"Key": "RenderTemplateId",
"Value": "~sitecollection/_catalogs/masterpage/Display Templates/Search/Item_Default.js",
"ValueType": "Edm.String"
},
{
"__metadata": {
"type": "SP.KeyValue"
},
"Key": "piSearchResultId",
"Value": "ARIAǂ36fbb1d6-41b5-3088-e44d-0ef0994f24b0ǂc0c4600e-e178-48f1-9902-f17e59e7670aǂ36fbb1d6-41b5-3088-e44d-0ef0994f24b0.1000.3ǂ",
"ValueType": "Edm.String"
},
{
"__metadata": {
"type": "SP.KeyValue"
},
"Key": "Rank",
"Value": "63752309979.3815",
"ValueType": "Edm.Double"
},
{
"__metadata": {
"type": "SP.KeyValue"
},
"Key": "GeoLocationSource",
"Value": "EUR",
"ValueType": "Edm.String"
},
{
"__metadata": {
"type": "SP.KeyValue"
},
"Key": "SiteId",
"Value": "cf4f80dc-68ed-46b6-b246-453c2089c03c",
"ValueType": "Edm.String"
},
{
"__metadata": {
"type": "SP.KeyValue"
},
"Key": "UniqueId",
"Value": "{674B8CAB-AC2D-4EE4-BB83-C37EAAF06C6B}",
"ValueType": "Edm.String"
},
{
"__metadata": {
"type": "SP.KeyValue"
},
"Key": "WebId",
"Value": "5b866fc8-edad-4d99-b3ad-bf1e58efde61",
"ValueType": "Edm.String"
},
{
"__metadata": {
"type": "SP.KeyValue"
},
"Key": "contentclass",
"Value": "STS_ListItem_DocumentLibrary",
"ValueType": "Edm.String"
},
{
"__metadata": {
"type": "SP.KeyValue"
},
"Key": "IsExternalContent",
"Value": "false",
"ValueType": "Edm.Boolean"
},
{
"__metadata": {
"type": "SP.KeyValue"
},
"Key": "ListId",
"Value": "8a69a0fc-de45-41e7-b679-1a49d461d4e0",
"ValueType": "Edm.String"
},
{
"__metadata": {
"type": "SP.KeyValue"
},
"Key": "PartitionId",
"Value": null,
"ValueType": "Null"
},
{
"__metadata": {
"type": "SP.KeyValue"
},
"Key": "UrlZone",
"Value": "0",
"ValueType": "Edm.Int64"
},
{
"__metadata": {
"type": "SP.KeyValue"
},
"Key": "Culture",
"Value": null,
"ValueType": "Null"
},
{
"__metadata": {
"type": "SP.KeyValue"
},
"Key": "DocumentSignature",
"Value": "-8973309957882017142;1499228324415174931;-855859975164701460;1416586343137351126;-4611572412426312091;1063957897948293849",
"ValueType": "Edm.String"
},
{
"__metadata": {
"type": "SP.KeyValue"
},
"Key": "CollapsingStatus",
"Value": "0",
"ValueType": "Edm.Int32"
}

Is there any way to exclude those from the search? If my results are 500 this is a big part of the whole response and I could improve my performance if SharePoint would not send this over.

Microsoft 365 and Office | SharePoint | Development
Microsoft 365 and Office | SharePoint | For business | Windows

2 answers

Sort by: Most helpful
  1. Manuel Javier Corral Gonzalez 0 Reputation points
    2025-02-15T15:08:13.7866667+00:00

    Greetings, you have tried using:

    "parameters/headers": {    "Accept": "application/json;odata=nometadata"  }
    

    Was this answer helpful?

    0 comments No comments

  2. Tong Zhang_MSFT 9,261 Reputation points
    2022-06-20T09:34:44.44+00:00

    Hi @davidelsner ,

    According to my research and testing ,please try to change your request body as follows, and check if the issue exists, hope it can help you .

    {  
      '__metadata': {  
        'type': 'Microsoft.Office.Server.Search.REST.SearchRequest'  
      },  
      'Querytext': 'xxxx',  
      'SelectProperties': {  
        'results': ['Title','Author']  
      }  
    }  
    

    For reference:
    https://learn.microsoft.com/en-us/sharepoint/dev/general-development/sharepoint-search-rest-api-overview#sample-get-request-8


    If the answer is helpful, please click "Accept Answer" and kindly upvote it. If you have extra questions about this answer, please click "Comment".
    Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.


    Was this answer helpful?


Your answer

Answers can be marked as 'Accepted' by the question author and 'Recommended' by moderators, which helps users know the answer solved the author's problem.