Examine - Is there a way to facetate string lists?

We’re building a site that’s going to have a quite advanced filter function. In order to use facets I’ve followed this guide Facetted search with Examine - Umbraco 13 - DEV Community and for simple string or integer values it works as expected but we have some properties that accepts one or more values, resulting on those values being saved in index as a comma separated list

The image shows a table with two columns, where the first column is labeled "SomeProperty" and the second column is labeled "Category one,Category Two." (Captioned by AI)

This whole string will then be counted as one facet. Is there a way of indexing string lists so each of these values are counted as one unique value?

P.S In later versions of Umbraco Examine 4 beta will break, there’s a work around here until it’s fixed: V4.0 Lucene 4.8.0-beta00017 breaking changes by DevAndersen · Pull Request #406 · Shazwazza/Examine · GitHub

1 Like

I don’t have a test site to play around with on this, but looking at the Examine documentation there’s a config for a multi value facet field. Although I think you’ll need to adjust how the value is being indexed (see multiple-values-per-field)

// Set field to be able to contain multiple values (This is default for a field in Examine. But you only need this if you are actually using multiple values for a single field)
facetsConfig.SetMultiValued("MultiIdField", true);

There was also a lengthy discussion over on Discord about this - hopefully that will contain some nuggets of information to help you out. It’s v10 but the principle is the same.

I’d be interested to hear how you get on with this :slight_smile:

Thank you! I’ll have a look and report back on how it went :slight_smile:

It worked like a charm! Thank you very much :).

I Just added

facetsConfig.SetMultiValued("categories", true);

In my IConfigureNamedOptions inherited class and in my IValueSetBuilder inherited class i simply passed an object as value to the field

var indexValues = new Dictionary<string, object>
{
    ...
    ["categories"] = new Object[] { "cat 1", "cat 2"}
    
};

yield return new ValueSet(content.Id.ToString(), IndexTypes.Content, "productSearchItem", indexValues);
1 Like