Azure Search task processor broken

Kashif Shah asked on December 8, 2020 17:20

Anyone have a workaround for Kentico.Libraries nuget package not supporting the latest version of Microsoft.Azure.Search nuget package?

Need the latest Microsoft.Azure.Search to use filterable integer collections in Azure Search.

The built-in Azure Search task processor now fails with the following exception:

Message: Could not load type 'Microsoft.Azure.Search.Models.SearchResult' from assembly 'Microsoft.Azure.Search.Data, Version=10.1.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35'.

Exception type: System.TypeLoadException
Stack trace:
at CMS.Search.Azure.SearchServiceManager.d__8.MoveNext()
at CMS.Search.Azure.SearchServiceManager.d__7.MoveNext()
at System.Linq.Enumerable.WhereSelectEnumerableIterator`2.MoveNext()
at System.Collections.Generic.List`1..ctor(IEnumerable`1 collection)
at System.Linq.Enumerable.ToList[TSource](IEnumerable`1 source)
at CMS.Search.Azure.SearchTaskEngineUtils.GetAllDocumentIdsByFilter(String indexName, String filter, SearchServiceManager searchService)
at CMS.Search.Azure.SearchTaskEngine.DeleteDocumentsFromSiteInSubTree(SearchTaskAzureInfo task, SearchIndexInfo index, SearchServiceManager searchServiceManager)
at CMS.Search.Azure.SearchTaskEngine.ExecuteDeleteTask(SearchTaskAzureInfo task)
at CMS.Search.Azure.SearchTaskExecutor.Execute(TaskInfo task)

Apparently SearchResult was removed and replaced with SearchResult< Document>

Correct Answer

Kashif Shah answered on December 9, 2020 20:51

It does appear that using Azure.Search.Documents (v11) side-by-side with Microsoft.Azure.Search (v5) is working as a workaround.

Heard back from Kentico Support that one needs to upgrade to X13 to use v10 of Microsoft.Azure.Search. Apparently X13 is still using the deprecated Microsoft library, too.

0 votesVote for this answer Unmark Correct answer

Recent Answers


Brenden Kehren answered on December 8, 2020 18:50

The workaround is to move back to an older version of the Azure Search package. There are also options to configure our search fields as well and make them do what you're looking for.

Check out the 2 global events:

DocumentFieldCreator.Instance.CreatingField.After += CreatingField_After;
DocumentCreator.Instance.AddingDocumentValue.Execute += AddingDocumentValue_Execute;

Here's something you can do to in the CreatingField_After event:

if (field.Name.Equals(nameof(TreeNode.NodeLevel), StringComparison.OrdinalIgnoreCase) ||
    field.Name.Equals(nameof(TreeNode.NodeOrder), StringComparison.OrdinalIgnoreCase))
{
    field.IsSortable = true;
    field.IsFilterable = true;
}
0 votesVote for this answer Mark as a Correct answer

Kashif Shah answered on December 8, 2020 18:57 (last edited on December 8, 2020 18:58)

Unfortunately, that is not a real workaround - we need to use the newer Azure Search API which is not supported with the Kentico Libraries version of Microsoft.Azure.Search.

Similarly, the search index is entirely custom (full-text pdf search of CDN hosted reference materials associated with Kentico hosted products), so a global event handler won't fit the bill.

0 votesVote for this answer Mark as a Correct answer

Kashif Shah answered on December 8, 2020 19:02 (last edited on December 8, 2020 19:02)

As an aside, the entirety of Microsoft.Azure.Search is deprecated and is supposed to be replaced by Azure.Search.Documents.

Although, that gives me an idea: might be able to workaround by using the Azure.Search.Documents library side-by-side with the Kentico supported, but deprecated Microsoft.Azure.Search.

Would be great if Kentico would release a hotfix supporting either the latest deprecated Microsoft.Azure.Search or switching to the correct Azure.Search.Documents...

0 votesVote for this answer Mark as a Correct answer

Brenden Kehren answered on December 8, 2020 19:03

Understood. Then the problem becomes if Kentico doesn't support the newer library you need to use, then you need to work with Kentico to make that work or find another solution.

If the index is entirely custom, what software is responsible for creating the objects in the index in Azure? The way Kentico works is you create the index in Azure, then connect it via the keys. Next when you build the index in Kentico it creates the objects/fields in the Azure index. So I'm not 100% sure how a global event handler would NOT work if Kentico is in charge of defining that initial creation of the objects/fields in the index. If you have a 3rd party system pushing data to the index, the fields should be created and defined already so you simply push our data to it.

0 votesVote for this answer Mark as a Correct answer

Kashif Shah answered on December 8, 2020 19:09

if Kentico doesn't support the newer library you need to use, then you need to work with Kentico to make that work or find another solution

Indeed, I've reached out to Kentico Support in the hopes that they will honor their 7-day fix guidance for this issue.

If the index is entirely custom, what software is responsible for creating the objects in the index in Azure?

Using a Kentico Scheduled Task that gets triggered when our product imports complete. That scheduled task makes a call to our custom document index class to kick off the bookkeeping for Azure Search.

0 votesVote for this answer Mark as a Correct answer

Kashif Shah answered on December 8, 2020 19:13

Thanks for your replies @BrendenKehren - you helped me maybe answer my own question. I will try out the idea of having both Azure libraries installed side-by-side to see if that works. Will update this question as appropriate, based on the results of that.

0 votesVote for this answer Mark as a Correct answer

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