MattW
(MattW)
August 15, 2025, 3:24pm
1
Hi all,
Been trying to follow blog posts and old discord threads to get Faceting working with no luck I am using 16.1.1
ArgumentException: field "$facets" was not indexed with SortedSetDocValues
I have the following code
appsettings:
"Examine": {
"LuceneDirectoryFactory": "TempFileSystemDirectoryFactory"
},
Composer :
builder.Services.ConfigureOptions<ConfigureExternalIndexOptions>();
ConfigureExternalIndexOptions:
internal class ConfigureExternalIndexOptions : IConfigureNamedOptions<LuceneDirectoryIndexOptions>
{
private static readonly string[] factedFields = [Constants.Search.ArticleTagsFieldName, Constants.Search.ArticleCategoriesFieldName];
public void Configure(string? name, LuceneDirectoryIndexOptions options)
{
if (name?.Equals(UmbConstants.UmbracoIndexes.ExternalIndexName) == false)
{
return;
}
options.FieldDefinitions.AddOrUpdate(new FieldDefinition(nameof(ArticlePage.PublishedDate), FieldDefinitionTypes.DateTime));
var facetsConfig = new FacetsConfig();
foreach (var field in factedFields)
{
facetsConfig.SetMultiValued(field, true);
options.FieldDefinitions.AddOrUpdate(new FieldDefinition(field, FieldDefinitionTypes.FacetFullText));
}
options.FacetsConfig = facetsConfig;
options.UseTaxonomyIndex = true;
}
}
SearchService (Cut down there is some optional filtering on the same facet fields)
var queryBuilder = index
.Searcher
.CreateQuery("content")
.NodeTypeAlias(ArticlePage.ModelTypeAlias)
.And()
.ParentId(listingPageId)
.WithFacets(facets => facets
.FacetString(Constants.Search.ArticleTagsFieldName)
.FacetString(Constants.Search.ArticleCategoriesFieldName)
);
Luke Index view (I have no idea what I am doing with this thing )
Thanks
Matt
mistyn8
(Mike Chambers)
August 16, 2025, 8:51am
2
Did you see Callum Whyte’s 2025 codegarden video.. just in case that is more up to date than any docs?
1 Like
MattW
(MattW)
August 16, 2025, 9:11am
3
Yes I have seen it but in the middle of battling with it completely forgot! I’ll go check it out again
Thanks
MattW
(MattW)
August 16, 2025, 10:03am
4
Sadly although I can step through the code it doesnt seem to effect the index. I added Callum’s path code and can see in Luke its till comma seperated
internal class ConfigureExternalIndexOptions : IConfigureNamedOptions<LuceneDirectoryIndexOptions>
{
private static readonly string[] factedFields = [Constants.Search.ArticleTags, Constants.Search.ArticleCategories];
private readonly ILoggerFactory _loggerFactory;
public ConfigureExternalIndexOptions(ILoggerFactory loggerFactory) => _loggerFactory = loggerFactory;
public void Configure(string? name, LuceneDirectoryIndexOptions options)
{
if (name?.Equals(UmbConstants.UmbracoIndexes.ExternalIndexName) == false)
{
return;
}
options.IndexValueTypesFactory = new Dictionary<string, IFieldValueTypeFactory>
{
{ "list", new DelegateFieldValueTypeFactory(fieldName => new ListValueType(fieldName, _loggerFactory)) },
};
options.FieldDefinitions.AddOrUpdate(new FieldDefinition(Constants.Search.ArticlePublishedDate, FieldDefinitionTypes.DateTime));
options.FieldDefinitions.AddOrUpdate(new FieldDefinition("path", "list"));
foreach (var field in factedFields)
{
options.FacetsConfig.SetMultiValued(field, true);
options.FieldDefinitions.AddOrUpdate(new FieldDefinition(field, FieldDefinitionTypes.FacetFullText));
}
}
public void Configure(LuceneDirectoryIndexOptions options) => Configure(string.Empty, options);
}
mistyn8
(Mike Chambers)
August 17, 2025, 7:45pm
5
Have you added the required ListValueType?
using Examine;
using Examine.Lucene.Indexing;
using Lucene.Net.Analysis;
using Lucene.Net.Documents;
using Microsoft.Extensions.Logging;
using Our.Umbraco.Extensions.Search.Analysis;
namespace Our.Umbraco.Extensions.Search.ValueTypes
{
public class ListValueType : IndexFieldValueTypeBase
{
public ListValueType(string fieldName, ILoggerFactory loggerFactory, char separator = ',')
: base(fieldName, loggerFactory)
{
Separator = separator;
}
public char Separator { get; }
protected override void AddSingleValue(Document doc, object value)
This file has been truncated. show original
MattW
(MattW)
August 17, 2025, 8:00pm
6
Yes, although I don’t think tags requires using it as the JSON is already tokenized properly as terms in the index.
mistyn8
(Mike Chambers)
August 18, 2025, 8:09am
7
not doubting you as could have changed in v16… but
`{ “json”, new DelegateFieldValueTypeFactory(fieldName => new JsonValueType(fieldName, _loggerFactory)) },`
umbraco-search-extensions/src/Our.Umbraco.Extensions.Search/Composing/ConfigureIndexOptions.cs at dev · callumbwhyte/umbraco-search-extensions
MattW
(MattW)
August 22, 2025, 8:03am
8
I found the issue for some reason my ConfigureOptions is gettng called before Umbraco, which overrrides everything. So I have move it to a PostConfigure call and it is now working.
system
(system)
Closed
September 21, 2025, 8:04am
9
This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.