Graph search query does not return SharePoint list items when using custom managed property

Joost van der Linden 126 Reputation points
2023-08-10T15:16:27.2966667+00:00

A few months ago I have created a custom list in a SharePoint Online Communication Site, and added a couple of columns to the list.

The list contains a bunch of items and the columns (crawled properties) are assigned to newly created managed properties. Both the site and the list are configured to be indexed by SharePoint search.

I am trying to perform a query to retrieve specific list items.

When I run the following query using the SharePoint Search Query Tool, I get the correct amount of results:

ChatRecipient="User DisplayName" AND Path:"https://tenant.sharepoint.com/sites/ActiviteitenTracker/Lists/Overzicht"

I get 24 hits.

However when I try to run the following query using the Microsoft Graph Explorer, I do not get any results:

Method: POST

URI: https://graph.microsoft.com/v1.0/search/query

Body:

{     
"requests": [         
{             "entityTypes": ["listItem"],
              "query": { 
                "queryString": "(ChatRecipient=\"User DisplayName\" AND Path:\"https://tenant.sharepoint.com/sites/ActiviteitenTracker/Lists/Overzicht\")"
             }
         }
     ] 
}

When I change the querystring by replacing the managed property 'ChatRecipient' with 'Title', then all of a sudden it works (hence with a built-in managed property):

{
    "requests": [
        {
            "entityTypes": [
                "listItem"
            ],
            "query": {
                "queryString": "(Title=\"999\" AND Path:\"https://tenantname.sharepoint.com/sites/ActiviteitenTracker/Lists/Overzicht\")"
            }
        }
    ]
}

Will Microsoft Graph Search query API actually work with managed properties that have been created at site collection level? Or does it only work with managed properties that have been created at the tenant level (propagated to all site collections)?

Or am I doing something wrong here?

Thanks for all help in advance.

Joost

Microsoft 365 and Office SharePoint For business Windows
Microsoft Security Microsoft Graph
0 comments No comments
{count} votes

2 answers

Sort by: Most helpful
  1. Anonymous
    2023-08-11T07:13:19.3933333+00:00

    Hi@Joost van der Linden

    Microsoft Graph Search query API supports both tenant-level and site collection-level managed properties.

    I see that it has no syntax errors, but the reason why it may not return any results is:

    You did not specify the siteId parameter, which is required for searches using site collection-level administrative properties.

    You used double quotes in your query, which may cause KQL to treat them as phrases instead of single words. You can try using single quotes or escaping special characters

    Please try:

    {
      "requests": [
        {
          "entityTypes": ["listItem"],
          "query": {
            "queryString": "(ChatRecipient='user@example.com' AND Path:'https://tenant.sharepoint.com/sites/ActiviteitenTracker/Lists/Overzicht')"
          },
          "siteId": "yoursite,5724d91f-650c-4810-83cc-61a8818917d6,c3ba25dc-2c9f-48cb-83be-74cdf68ea5a0(Yoursite id)"
        }
      ]
    }
    
    

    https://learn.microsoft.com/en-us/graph/api/resources/search-api-overview?view=graph-rest-1.0

    Here is link about get site id for your reference::

    https://learn.microsoft.com/en-us/graph/api/site-get?view=graph-rest-1.0&tabs=http


    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.

    Best Regards

    Cheng Feng


  2. Anonymous
    2023-09-05T06:35:38.2333333+00:00

    HI @Joost van der Linden

    I'm glad to hear you solve the problem ,if you have any issue about SharePoint, you are welcome to raise a ticket in this forum.

    By the way, since the Microsoft Q&A community has [a policy]1 that "The question author cannot accept their own answer. They can only accept answers by others." and according to the scenario introduced here: Answering your own questions on Microsoft Q&A, I would make a brief summary of this thread:

    [Graph search query does not return SharePoint list items when using custom managed property]

    Issue Symptom:

    When I change the querystring by replacing the managed property 'ChatRecipient' with 'Title', then all of a sudden it works (hence with a built-in managed property)

    Solution:

    When I mapped the crawled properties to an available RefinableString managed property, and used this in my query it worked fine.

    You could click the "Accept Answer" button for this summary to close this thread, and this can make it easier for other community member's to see the useful information when reading this thread. Thanks for your understanding!

    0 comments No comments

Your answer

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