question

JeromeMZK-2604 avatar image
0 Votes"
JeromeMZK-2604 asked JeromeMZK-2604 answered

SharePoint Search REST API - PrimaryQueryResult is null

I develop a SPFX WebPart that uses the SharePoint Search REST API. This SPFX WP is used in several tenants.

The request is this below:

 {
     "request": {
         "__metadata": {
             "type": "Microsoft.Office.Server.Search.REST.SearchRequest"
         },
         "Querytext": "ContentClass:STS_Site AND WebTemplate:GROUP (NOT PrivacyIndicator:4) Title:test* ",
         "RowLimit": 20,
         "TrimDuplicates": false,
         "SortList": {
             "results": [
                 {
                     "Direction": 1,
                     "Property": "LastModifiedTime"
                 }
             ]
         },
         "SelectProperties": {
             "results": [
                 "LastModifiedTime",
                 "Description",
                 "Title",
                 "Author",
                 "OriginalPath",
                 "UniqueId",
                 "SiteID",
                 "WebId",
                 "SiteLogo",
                 "People",
                 "AuthorOWSUSER",
                 "Created",
                 "WebTemplate",
                 "GroupId",
                 "PrivacyIndicator"
             ]
         },
         "Properties": {
             "results": [
                 {
                     "Name": "EnableDynamicGroups",
                     "Value": {
                         "BoolVal": true,
                         "QueryPropertyValueTypeIndex": 3
                     }
                 }
             ]
         },
         "HitHighlightedProperties": {
             "results": []
         },
         "RefinementFilters": {
             "results": []
         }
     }
 }

A. When the response has some results, there is no problem.

B. When this request has no result, for all tenants except one, the response has this body:

     {
         "odata.metadata": ".../_api/$metadata#Microsoft.Office.Server.Search.REST.SearchResult",
         "ElapsedTime": 32,
         "PrimaryQueryResult": {
             "CustomResults": [],
             "QueryId": "762be03b-ae4f-438e-984d-4f81d2416506",
             "QueryRuleId": "00000000-0000-0000-0000-000000000000",
             "RefinementResults": null,
             "RelevantResults": {
                 "GroupTemplateId": null,
                 "ItemTemplateId": null,
                 "Properties": [ ... ],
                 "ResultTitle": null,
                 "ResultTitleUrl": null,
                 "RowCount": 0,
                 "Table": {
                     "Rows": []
                 },
                 "TotalRows": 0,
                 "TotalRowsIncludingDuplicates": 0
             },
             "SpecialTermResults": null
         },
         "Properties": [ ... ],
         "SecondaryQueryResults": [],
         "SpellingSuggestion": "",
         "TriggeredRules": []
     }

=> PrimaryQueryResult has a correct value and specifies that there are no result (TotalRows is 0).

C. When this request has no result, for one specific tenant, the response has this unexpected body:

     {
         "odata.metadata": ".../_api/$metadata#Microsoft.Office.Server.Search.REST.SearchResult",
         "ElapsedTime": 35,
         "PrimaryQueryResult": null,
         "Properties": [ ... ],
         "SecondaryQueryResults": [ ... ],
         "SpellingSuggestion": "",
         "TriggeredRules": [ ... ]
     }

=> The problem here is that PrimaryQueryResult is null, unlike all other tenants.


What could cause this behavior?
In what cases can PrimaryQueryResult be null?

office-sharepoint-onlinesharepoint-dev
5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

RaytheonXie-MSFT avatar image
0 Votes"
RaytheonXie-MSFT answered

Hi @JeromeMZK-2604 ,
Could you confirm that the different tenants take different permissions?Permission will affect the result of query.


If an Answer is helpful, please click "Accept Answer" and upvote it.
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.


5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

JeromeMZK-2604 avatar image
0 Votes"
JeromeMZK-2604 answered JeromeMZK-2604 edited

Thank you for your answer.

I'm not sure to understand your question: what kind of permissions are you talking about?
These different tenants are those of my different customers.

· 4
5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

Hi @JeromeMZK-2604 ,
The tenants take different permissions of the site contents might affect the search result.

0 Votes 0 ·

I'm sorry but I still don't understand what permissions on the tenant level you are talking about.
It's probably a possible way to explore but I don't know where to look.

And these "permissions" at the tenant level would affect the PrimaryQueryResult property?
I've been developing in SharePoint since SP Server 2007 and I've never seen this behavior before.

How can I reproduce this behavior (PrimaryQueryResult = null) on my development tenant?

Thank you again for your answers ^^

0 Votes 0 ·
linyus avatar image
0 Votes"
linyus answered WendyLi-MSFT commented

Please make sure your account has read permission in the talent.
You can crawled items after you have permission in the site.
You can't get any items if you don't have permission in the site.

· 1
5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

@JeromeMZK-2604 Please check if linyus's answer helps you. If you have any concerns, please feel free to reply.

0 Votes 0 ·
JeromeMZK-2604 avatar image
0 Votes"
JeromeMZK-2604 answered

@WendyLi-MSFT I'm sorry but this answer doesn't answer my problem.
I have all the rights I need at all levels.
The problem is something else.

The problem is not about having access to elements or not but that the search service returns a PrimaryQueryResult to null for a single tenant when there is no result to a query.


5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.