AdvantageCMS.Core.Common.BaseClasses Namespace
Build With Advantage

SearchIndexer..::..Dispatcher_Action Method

Handles the Action event of the SearchIndexer.

Namespace:  AdvantageCSP.Keyoti.SiteIndexer
Assembly:  AdvantageCSP.Keyoti.SiteIndexer (in AdvantageCSP.Keyoti.SiteIndexer.dll)

Syntax


public void Dispatcher_Action(
	Object sender,
	ActionEventArgs e
)

Parameters

sender
Type: Object
The source of the event.
e
Type: ActionEventArgs
The ActionEventArgs instance containing the event data.

Remarks


Every crawl decision this indexer makes happens here. The dispatcher raises the actions in crawl order, and each case below owns one step:

ActionWhat this indexer does
ImportStartedClears the link sets, loads the previous run's page map into PreviousScrapeResults, deletes the old 404.txt, and calls WarmUpSite so the first real request does not pay the application's cold-start cost.
IsDocumentToBeCrawledPrescreenSets WillCrawl = false for URLs rejected by IsInvalidUrl or already present in ProcessedLinks/NotFoundLinks. This is the cheapest place to stop work — the request is never issued.
UseDocumentEncodingLeft as a no-op; the document's own encoding is accepted.
ResponseFromServerReceivedAllocates the current PageInformation and AIInfo from the response and records whether the URL should be processed at all.
ResponseErrorFromServerReceivedFiles the URL under NotFoundLinks (404) or ErrorLinks (anything else, also written to the log table).
RawBodyReceivedCaptures the response body length and, when the domain has the AI payload enabled, stashes the raw text for later cleaning.
ReadingTextRuns VerifyDomain against the parsed document and turns processing off when the page belongs to another domain or language; harvests title, meta data and categories.
ReadLinksDe-duplicates the harvested links, records which page each link was found on in LinkDocumentMapList, then prunes the list through GetUniqueListUri.
IsDocumentToBeIndexedThe final gate: detects redirects, honours the processing flag, and skips pages whose timestamp and length match the previous run.
DocumentIndexedRecords the URL as processed and writes its payload.
AutoAssignContentDelegates to AssignDefaultContentCategories(Object, ActionEventArgs).
ImportFinishedWrites the 404 report, clears the sets, and sets ScrapeComplete so BuildIndex()()()() can safely prune stale documents.

RequestingUri()()()() is deliberately absent. The base subscribes its own handler ahead of this one and uses that action to attach the domain's cookies, the configured request headers, the search key and the platform user agent to every outgoing request. A custom indexer that handles RequestingUri runs second and may adjust the request the base prepared, but must not rebuild it from scratch — doing so drops the search-key header and the domain/language cookies, and the crawler starts indexing the wrong language's pages.

Ordering is a real constraint, not a style choice. PageInformation is only allocated on ResponseFromServerReceived()()()(), so any action that fires before it — or for a URL whose response never arrived — reads the previous page's object. The error case here mutates that stale instance instead of allocating a fresh one; a custom indexer is better off allocating.

Examples


The three cases a custom indexer cannot skip: reset state at the start, prune the link list, and finish the pass.
C#
public override void Dispatcher_Action(object sender, ActionEventArgs e)
{
    switch (e.ActionData.Name)
    {
        case ActionName.ImportStarted:
            ProcessedLinks = new HashSet<string>();
            NotFoundLinks = new HashSet<string>();
            ErrorLinks = new HashSet<string>();
            PreviousScrapeResults = SearchHelper.GetPageLinksFromFile(Configuration);
            WarmUpSite(e);
            break;

        case ActionName.ReadLinks:
            GetUniqueListUri((ArrayList)e.ActionData.Data);
            break;

        case ActionName.ImportFinished:
            Generate404List();
            NotFoundLinks.Clear();
            ErrorLinks.Clear();
            break;
    }
}