Create a JavaScript trigger to get a set of URLs
A trigger is the starting point that Sitecore Search uses to look for content to index. Define a JavaScript trigger when you want to use a JavaScript function that returns a set of URLs.
To create a JavaScript trigger:
-
On the menu bar, click Sources , and select the crawler source you created.
-
On the Source Settings page, next to Triggers, click
Edit. -
In the Trigger Type drop-down menu, click JS.
-
In the Trigger Source field, paste the JavaScript function.
For example, paste:
This sample function uses a
forloop to iterate over a URL in increments of 100. Each iteration results in one URL. In this example, there will be 11 loops, resulting in 10 URLs. This is because, on the eleventh loop,i=1100, which is greater than themaxof 1000, and the function stops.This function gives the following output:
-
In the Timeout field, enter the time in milliseconds that the crawler waits for a response from the JS function.
For example, enter 5000.
-
Click Save.