SPO-Trigger-Reindex icon indicating copy to clipboard operation
SPO-Trigger-Reindex copied to clipboard

is:issue is:open how can we trigger incremental crawl when new docs are added and they need to be searched immediately-"startFullCrawl": true powerautomate http post

Open swiftinitdotcom opened this issue 2 years ago • 4 comments

is:issue is:open how can we trigger incremental crawl when new docs are added and they need to be searched immediately-"startFullCrawl": true powerautomate http post

I tried below- Create a new Power Automate flow and choose "HTTP" as the trigger. Add an "HTTP" action to make a POST request to the SharePoint Search REST API endpoint. The URL for the endpoint is typically in the format: https:///_api/search/admin/fullcrawl. In the "Headers" section of the HTTP action, add the following key-value pairs: "Accept": "application/json;odata=verbose" "Content-Type": "application/json;odata=verbose" "X-RequestDigest": "<RequestDigest>" (you will need to obtain the RequestDigest value from the SharePoint site) In the "Body" section of the HTTP action, add the following JSON payload: json Copy code { "startFullCrawl": true } Save the flow and test it by running it. This should trigger a full search crawl on the SharePoint site. Note: The above steps assume that you have the necessary permissions to trigger search crawls on the SharePoint site.

Ami Loh how to use graph api to search document libraries You can use Microsoft Graph API to search for documents in a SharePoint document library by making a GET request to the /search endpoint. Here's an example of how you can search for all documents in a document library named "Documents" in a site named "MySite":

Construct the URL for the search request: https://graph.microsoft.com/v1.0/sites/MySite:/drive/root/search(q='fileExtension:docx') Add an "Authorization" header to the request with a valid access token. Send the GET request to the URL. The response will contain an array of search results, each of which represents a document in the document library. You can use the properties of each search result, such as webUrl, to access the document or to display information about it.

Note: You'll need to have the necessary permissions to access the SharePoint site and document library, as well as to make requests to the Microsoft Graph API.

{ "startFullCrawl": true }

swiftinitdotcom avatar Jan 31 '23 15:01 swiftinitdotcom

There is no incremental crawl, only continous. Any queuing of full crawl/re-crawl will only have an adverse affect on indexing.

A change on an item will be picked up automatically depending on overall farm load (shared by all tenants on a farm).

Re-crawl should only be clicked or scheduled when there is a schema change impacting existing items.

wobba avatar Jan 31 '23 18:01 wobba

Thank you for your help. Maybe we will use graph API to search recently uploaded document.

Thanks and regards,

Amit Lohogaonkar

swiftinitdotcom avatar Jan 31 '23 18:01 swiftinitdotcom

How do we instantly search recently uploaded documents without waiting for 30 minutes or 1 hr call, can we write some workaround where there is second mehtod that will also check for last 1 hr uploaded files(in file upload event we will store those doc id's in one list saying last 1 hr files uploaded or modfied with their content or metadata) and then use graph api or rest api to parse through those id's(for example 5 documents uploaded or modified in last 45 minutes) and then we also take those in account. https://powerusers.microsoft.com/t5/Using-Flows/flow-example-using-rest-api-to-search-sharepoint-documents/td-p/865547 Because when new 50 documents are uploaded if other users searching they are invisible for 1 hr or so depending on crawl schedule

swiftinitdotcom avatar Feb 01 '23 05:02 swiftinitdotcom

There is no way to control the latency as I said. If you want to surface docs instantly somewhere you cannot use the search API.

wobba avatar Feb 01 '23 19:02 wobba