search via msgraph using custom search schema from a specific sitecollection

Marco Dissel 26 Reputation points
2023-02-06T13:14:23.6233333+00:00

How can I specify the site collection that should be used when doing an msgraph search using the custom search schema from a sitecollection

When using the Sharepoint API, you just use /sites/search/_api/search, but I can't find a setting how to force the msgraph to use the search schema from a specific site collection.

Microsoft Graph
Microsoft Graph
A Microsoft programmability model that exposes REST APIs and client libraries to access data on Microsoft 365 services.
10,293 questions
0 comments No comments
{count} votes

2 answers

Sort by: Most helpful
  1. HarmeetSingh7172 4,886 Reputation points
    2023-02-06T22:00:55.3833333+00:00

    Hello @Marco Dissel

    Thanks for reaching out!

    You can specify the collection of sites in your query string like this:

    POST /search/query  
     
    {  
         "requests": [  
             {  
                 "entityTypes": [  
                     "driveItem"  
                 ],  
                 "query": {  
                     "queryString": "sample AND (Path:https://contoso.sharepoint.com/sites/sitename1 OR Path:https://contoso.sharepoint.com/sites/sitename2 OR 
    Path:https://contoso.sharepoint.com/sites/sitename3
    )"  
                 }  
             }  
         ]  
     } 
    

    Refer this similar post and documentation.

    You can only fetch managed properties in Graph API response. If you are looking to fetch any custom field which is not predefined crawled property, you need to add it to search schema, manage-search-schema.

    Hope this helps.

    If the answer is helpful, please click "Accept Answer" and kindly upvote it. If you have extra questions about this answer, please click "Comment".


  2. Deleted

    This answer has been deleted due to a violation of our Code of Conduct. The answer was manually reported or identified through automated detection before action was taken. Please refer to our Code of Conduct for more information.


    Comments have been turned off. Learn more