location
field:
location
field:
Europe
level-0 (or root) category and the Europe > Germany
level-1 category, and so forth. Through this indexing scheme, you can get facet counts for all documents that belong to the Europe > Germany
category (at level 1) by querying for “1/Europe/Germany” as a Solr facet prefix, but equally all documents that as a result belong to Europe
at a broader level. Finally this allows us to also get facet counts for all documents with any location
value by requesting “0/” as a facet prefix, for example.
facet.prefix = 0/
) and also determine which of the nodes at a given level have children (using a single facet query).
More specifically, for each hierarchical facet my_facet
, you create an additional meta-facet named my_facet_parents
that contains information about the taxonomy categories that have children (that is, those nodes that are not leaf nodes in the hierarchy). Using the example from above, you would index location
in exactly the same way as before. In addition, you would index these terms for the new location_parents
meta-facet:
location_parents
field has all the same index terms as location
except the last level is omitted. The intended meaning is that Doc#1 is indexed with the term 0/Europe
in location_parents
because it contains location
values that are the children of Europe
, and so forth.