Press Ctrl / CMD + C to copy this to your clipboard.
This post will be reported to the moderators as potential spam to be looked at
I'm trying to create a new index using Examine 3 in an Umbraco 10 project.
I'm following the documentation for Umbraco 10 to create a custom index - https://our.umbraco.com/Documentation/Reference/Searching/Examine/indexing/#creating-your-own-index.
The index is registered and I can see it in the backoffice, but it has no records in it and I cannot rebuild it through the backoffice because:
This index cannot be rebuilt because it has no assigned IIndexPopulator.
I have created a ProductIndexPopulator:
ProductIndexPopulator
public class ProductIndexPopulator : IndexPopulator { private readonly IContentService _contentService; private readonly ProductIndexValueSetBuilder _productIndexValueSetBuilder; public ProductIndexPopulator(IContentService contentService, ProductIndexValueSetBuilder productIndexValueSetBuilder) { _contentService = contentService ?? throw new ArgumentNullException(nameof(contentService)); _productIndexValueSetBuilder = productIndexValueSetBuilder ?? throw new ArgumentNullException(nameof(productIndexValueSetBuilder)); RegisterIndex("ProductIndex"); } protected override void PopulateIndexes(IReadOnlyList<IIndex> indexes) { // blah blah blah } }
And registered it in a composer:
public class SearchComposer : IComposer { public void Compose(IUmbracoBuilder builder) { builder.Services.AddExamineLuceneIndex<ProductIndex, ConfigurationEnabledDirectoryFactory>("ProductIndex"); builder.Services.ConfigureOptions<ConfigureProductIndexOptions>(); builder.Services.AddSingleton<ProductIndexValueSetBuilder>(); builder.Services.AddSingleton<ProductIndexPopulator>(); } }
Anybody seen this issue before/know what I'm missing?
I don't think the docs are accurate and I can't find any U10 examples.
Thanks
I was having the exact same issue, I have been able to register the IndexPopulator correctly, however when I add the Validator into the Index to restrict to a certain document type it stops working.
In the composer:
builder.Services.AddSingleton<ProductIndexPopulator>();
becomes
builder.Services.AddSingleton<IIndexPopulator, ProductIndexPopulator>();
But as I said, even though the index can now be built / rebuilt it will be empty if you try to restrict it
Does it register and populate WITHOUT the Validator?
Yep, if I remove the validator it works.
By the validator I mean this line:
options.Validator = new ContentValueSetValidator(true, false, _publicAccessService, _scopeProvider, includeItemTypes: new List<string>{"product"});
I've had some code given to me by @AndreyKarandas4 on Twitter which works
using Examine; using Examine.Lucene; using Microsoft.Extensions.Logging; using Microsoft.Extensions.Options; using Umbraco.Cms.Core.Hosting; using Umbraco.Cms.Core.Services; using Umbraco.Cms.Infrastructure.Examine; public class MapIndex : UmbracoExamineIndex, IUmbracoContentIndex, IDisposable { private string[] contentTypes = new string[] { "documentType" }; public MapIndex( ILoggerFactory loggerFactory, string name, IOptionsMonitor<LuceneDirectoryIndexOptions> indexOptions, IHostingEnvironment hostingEnvironment, IRuntimeState runtimeState) : base(loggerFactory, name, indexOptions, hostingEnvironment, runtimeState) { loggerFactory.CreateLogger<MapIndex>(); LuceneDirectoryIndexOptions namedOptions = indexOptions.Get(name); if (namedOptions == null) { throw new InvalidOperationException($"No named {typeof(LuceneDirectoryIndexOptions)} options with name {name}"); } namedOptions.FieldDefinitions = new( new("id", FieldDefinitionTypes.Integer) ); if (namedOptions.Validator is IContentValueSetValidator contentValueSetValidator) { PublishedValuesOnly = contentValueSetValidator.PublishedValuesOnly; } } void IIndex.IndexItems(IEnumerable<ValueSet> values) => PerformIndexItems(values.Where(v => contentTypes.Any(x => x == v.ItemType)), OnIndexOperationComplete); }
Then in your composer:
builder.Services.AddExamineLuceneIndex<MapIndex, ConfigurationEnabledDirectoryFactory>("indexName");
Indeed, when following this tutorial I was getting the same: https://docs.umbraco.com/umbraco-cms/v/10.latest-lts/reference/searching/examine/indexing
This index cannot be rebuilt because it has no assigned IIndexPopulator
However this seemed to be due that I did not replace reference to "ProductIndex" in RegisterIndex call in IndexPopulator.
RegisterIndex
IndexPopulator
Once I replaced it with my index name - it started working.
is working on a reply...
This forum is in read-only mode while we transition to the new forum.
You can continue this topic on the new forum by tapping the "Continue discussion" link below.
Continue discussion
Umbraco 10 custom index registering but not populating due to IIndexPopulator
I'm trying to create a new index using Examine 3 in an Umbraco 10 project.
I'm following the documentation for Umbraco 10 to create a custom index - https://our.umbraco.com/Documentation/Reference/Searching/Examine/indexing/#creating-your-own-index.
The index is registered and I can see it in the backoffice, but it has no records in it and I cannot rebuild it through the backoffice because:
I have created a
ProductIndexPopulator:And registered it in a composer:
Anybody seen this issue before/know what I'm missing?
I don't think the docs are accurate and I can't find any U10 examples.
Thanks
I was having the exact same issue, I have been able to register the IndexPopulator correctly, however when I add the Validator into the Index to restrict to a certain document type it stops working.
In the composer:
becomes
But as I said, even though the index can now be built / rebuilt it will be empty if you try to restrict it
Does it register and populate WITHOUT the Validator?
Yep, if I remove the validator it works.
By the validator I mean this line:
I've had some code given to me by @AndreyKarandas4 on Twitter which works
Then in your composer:
Indeed, when following this tutorial I was getting the same: https://docs.umbraco.com/umbraco-cms/v/10.latest-lts/reference/searching/examine/indexing
However this seemed to be due that I did not replace reference to "ProductIndex" in
RegisterIndexcall inIndexPopulator.Once I replaced it with my index name - it started working.
is working on a reply...
This forum is in read-only mode while we transition to the new forum.
You can continue this topic on the new forum by tapping the "Continue discussion" link below.