When to use custom pivots and facets in Zotonic

I am adding some custom fields to the page resource, rsc, in Zotonic. I must say that I appreciate how easy it is, just do an update with a map with a key-value and that it is also possible to add a deep structure.

  m_rsc:update(Id, #{<<"deepmap">> =>
                       #{<<"p1">> => <<"hello">>, <<"p2">> => <<"world">>}},
               Context).

and then access it in the template like m.rsc[id].deepmap.p1
And deletion seems to work by updating with the map value set to undefined for the key. This is all very handy when accessing json structures from external sources that are decoded to Erlang maps, you can just “dump” the decoded structure into your resource.

I have also added some custom pivot table to be able to sort/filter on some fields. Now I also noted that there is a “facet” table into which you can store values for sorting/filtering but I do not understand when to use this. Is there some rule of thumb or recommendation on when to use custom pivots and when to use facets?
Thanks,
Mikael

1 Like

Hi!

The faceted search is for when you want to be able to “drill down” in the search results.
Bit like e-commerce sites.

You can see the faceted search in action here:

https://www.atlasofmutualheritage.nl/en/search

The column on the left with the numbers are the facets.
The facets are defined in a template, check pivot/facet.tpl

2 Likes