Bram
09/02/2024, 9:24 AMpublic static ICollection<LuceneFacetModel> GetFacetValues(this ISearchResults results, string field)
{
return results.GetFacet(field)
.Select(f => new LuceneFacetModel
{
Count = (int)f.Value,
Id = f.Label
})
.ToList();
}
However I get an error that System.ArgumentNullException: 'Value cannot be null. Arg_ParamName_Name'
This is weird, since even when there are no facets you'd just want to return an empty list.
I have registered the facet that I'm looking for by using this in my ConfigureNamedOptions implementation.
var facetsConfig = new FacetsConfig();
facetsConfig.DimConfigs.Add(Defaults.ParkFields.RelatedFacilities, new FacetsConfig.DimConfig { IsMultiValued = true });
// set facetFullText fields
// Note: https://shazwazza.github.io/Examine/articles/configuration.html contains all facetable fields.
options.FieldDefinitions.AddOrUpdate(new FieldDefinition(Defaults.ParkFields.RelatedFacilities, FieldDefinitionTypes.FacetFullText));
options.FacetsConfig = facetsConfig;
Does anyone know why this code, while searching for the field Defaults.ParkFields.RelatedFacilities would throw this exception?Bram
09/02/2024, 9:34 AM