Can someone help me with refining Search REST API?

captain_atharv 511 Reputation points
2023-01-13T10:01:08.4+00:00

Hi,

I'm using Sharepoint Search REST API

I need to refine my query for below usecases:

  1. Search only for documents - include doc, images, ppt, etc and skip folders.
  2. Search in list - search for Querytext in specified list

Can this be achieved? I'm not able to find any documentation around it.

Microsoft Graph
Microsoft Graph
A Microsoft programmability model that exposes REST APIs and client libraries to access data on Microsoft 365 services.
10,515 questions
SharePoint
SharePoint
A group of Microsoft Products and technologies used for sharing and managing content, knowledge, and applications.
9,559 questions
SharePoint Development
SharePoint Development
SharePoint: A group of Microsoft Products and technologies used for sharing and managing content, knowledge, and applications.Development: The process of researching, productizing, and refining new or existing technologies.
2,655 questions
0 comments No comments
{count} votes

Accepted answer
  1. Srinivasa Rao Darna 6,686 Reputation points Microsoft Vendor
    2023-01-14T08:45:12.34+00:00

    Hello @captain_atharv ,

       POST /search/query
       
       {
           	"requests": [{
           		"entityTypes": [
           			"driveItem"
           		],
           		"query": {
           			"queryString": "{searchstring} AND ContentType:Document"
           		}
           	}]
           }
    
    • Search in list - search for Querytext in specified list

    A sample snippet using Microsoft Graph Search API using path to search in a specific list:

       POST /search/query
       {
       	"requests": [{
       		"entityTypes": [
       			"list",
       			"listItem"
       		],
       		"query": {
       			"queryString": "{searchstring} AND path:https://{tenant}.sharepoint.com/sites/MSGraph/Lists/Sample"
       		}
       	}]
       }
    

    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".

    1 person found this answer helpful.
    0 comments No comments

0 additional answers

Sort by: Most helpful