Suppress Search Task

James Mosquito asked on March 18, 2021 12:48

Hi,

I have an import task that creates documents if they do not exist or updates them if they do.

When doing an update, in some cases I would like to suppress a smart search task from being added (if a condition matches).

If I wrap the entire task logic in the Execute method with:

using (var context = new CMSActionContext())
{
    context.CreateSearchTask = false;

    _importService.Import();
}

No search tasks are added (including when new pages are added).

If I add a method to my service to suppress single documents from adding a search task as follows:

public void UpdateDocumentWithoutIndexing(TreeNode document)
{
    using (var context = new CMSActionContext())
    {
        context.CreateSearchTask = false;

        document.Update();
    }
}

A search task is still being added.

I also tried substituting CMSActionContext with DocumentActionContext with the same result.

Is what I am trying to do possible, or are there any other ideas I can try out?

Thanks, James

Recent Answers


James Mosquito answered on March 18, 2021 18:55

This is resolved now. The additional tasks were caused when assigning documents to page categories and when attaching/deleting media attachments which I have been able to suppress using a combination of the above and by deferring the changes if they have already been assigned.

Thanks, James

0 votesVote for this answer Mark as a Correct answer

   Please, sign in to be able to submit a new answer.