I'm trying to create custom index with ExamineX using Azure AI search service on empty Umbraco 10. Currently I use free tier and no license for ExamineX, I disabled MembersIndex in settings and just want to create custom NewsIndex that will store only nodes of content type 'news' — this is going to be 3rd index available in such setup.
As a roadmap I use this page https://docs.umbraco.com/umbraco-cms/v/10.latest-lts/reference/searching/examine/indexing about how to create custom index with local Examine. Also I read quite thoroughly https://examinex.online. I have partial success which is my NewsIndex is created in Azure Service and seen in Umbraco. However I can not properly implement publish/rebuild logic for it — whatever I do, it throws NRE somewhere in ExamineX.Shared.Umbraco code with no info I can use.
Just wander is there may be any kind of step-by-step instructions for this? Could not find it. Or will appreciate some code snippet :) Thanks in advance.
So going from normal Examine (disc) to ExamineX, you can update your custom index to inherit UmbracoContentAzureSearchIndex and update your composer to use AddExamineXAzureSearchIndexFromUmbraco.
Hi Lewis, sorry, missed your previous comment. Thanks for the info re index class, actually a week ago I came to that by myself also. Now I'm trying to get the index properly populated. I intentionally added extra logging and see that content nodes are indeed get indexed. But by some reason in backend Umbraco still does not show expected status.
My classes are quite close to Umbraco docs. Here is Populator method:
protected override void PopulateIndexes(IReadOnlyList<IIndex> indexes)
{
foreach (IIndex index in indexes)
{
//Go over all the content and index it if it fits the criteria
IContent[] roots = _contentService.GetRootContent().ToArray();
index.IndexItems(_newsIndexValueSetBuilder.GetValueSets(roots));
foreach (var root in roots)
{
const int pageSize = 10000;
var pageIndex = 0;
IContent[] descendants;
//Weird syntax, but it follows the Umbraco docs
do
{
descendants = _contentService.GetPagedDescendants(root.Id, pageIndex, pageSize, out _).ToArray();
IEnumerable<ValueSet> valueSets = _newsIndexValueSetBuilder.GetValueSets(descendants);
index.IndexItems(valueSets);
}
while (descendants.Length == pageSize);
}
}
}
and here is GetValueSets method with extra logging. Here I am adding all the content node's properties as index field:
public IEnumerable<ValueSet> GetValueSets(params IContent[] contents)
{
foreach (var content in contents.Where(x => _contentTypes.Contains(x.ContentType.Alias) && x.Published))
{
_logger.LogDebug("---------------- Indexing content item ID: {id}, name: {name}", content.Id, content.Name);
var indexValues = new Dictionary<string, object>
{
//This is where we assign our fields defined in options
[UmbracoExamineFieldNames.NodeNameFieldName] = content.Name!,
["id"] = content.Id,
["parentId"] = content.ParentId,
["nodeName"] = content.Name!,
[SearchKeys.POSTED_DATE_FIELD] = content.CreateDate,
[SearchKeys.POSTED_DATE_TICKS_FIELD] = content.CreateDate.Ticks
};
foreach (var property in content.Properties) indexValues[property.Alias] = property.GetValue();
var valueSet = new ValueSet(content.Id.ToString(), IndexTypes.Content, content.ContentType.Alias, indexValues);
yield return valueSet;
}
}
Log messages from this method come through and I see them in Umbraco logs, but index is still empty and configured for 8 fields instead of many more. In Azure Search service - the same....... So still fighting..
ExamineX custom index
Hello community,
I'm trying to create custom index with ExamineX using Azure AI search service on empty Umbraco 10. Currently I use free tier and no license for ExamineX, I disabled MembersIndex in settings and just want to create custom NewsIndex that will store only nodes of content type 'news' — this is going to be 3rd index available in such setup.
As a roadmap I use this page https://docs.umbraco.com/umbraco-cms/v/10.latest-lts/reference/searching/examine/indexing about how to create custom index with local Examine. Also I read quite thoroughly https://examinex.online. I have partial success which is my NewsIndex is created in Azure Service and seen in Umbraco. However I can not properly implement publish/rebuild logic for it — whatever I do, it throws NRE somewhere in ExamineX.Shared.Umbraco code with no info I can use.
Just wander is there may be any kind of step-by-step instructions for this? Could not find it. Or will appreciate some code snippet :) Thanks in advance.
Hi Yuri,
Im having the same issue and finding myself going round in circles.
Did you get anywhere towards resolving this?
Lewis
So i got to the bottom of this one. (Or my colleague did)
Here is my custom index class, as well as the but that needs adding to the composer.
So going from normal Examine (disc) to ExamineX, you can update your custom index to inherit
UmbracoContentAzureSearchIndex
and update your composer to useAddExamineXAzureSearchIndexFromUmbraco
.Hi Lewis, sorry, missed your previous comment. Thanks for the info re index class, actually a week ago I came to that by myself also. Now I'm trying to get the index properly populated. I intentionally added extra logging and see that content nodes are indeed get indexed. But by some reason in backend Umbraco still does not show expected status.
My classes are quite close to Umbraco docs. Here is Populator method:
and here is GetValueSets method with extra logging. Here I am adding all the content node's properties as index field:
Log messages from this method come through and I see them in Umbraco logs, but index is still empty and configured for 8 fields instead of many more. In Azure Search service - the same....... So still fighting..
In case anyone is interested in the topic, here is very basic Umbraco solution with custom ExamineX index configuration - github
is working on a reply...