Skip to main content

HierarchyTransformer

Adds hierarchical tags to documents using a delimiter for structured categorization.

Notes

Given a separator, split a field string into multiple segments representing each node of a hierarchical branch. This is useful when faceting, to find out how many documents fall under each node of a hierarchy. For example, take this hierarchical string:

/vegetable/potato/sweet

We specify a slash (/) separator and it will produce the following entries in the specified document metadata field:

/vegetable

/vegetable/potato
/vegetable/potato/sweet

If no target field is specified toField the source field fromField will be used to store the resulting values. The same applies to the source and target hierarchy separators (fromSeparator and toSeparator).

You can keepEmptySegments, as well as specify whether the fromSeparator is a regular expression. When using regular expression without a "toSeparator", the text matching the expression is kept as is and thus can be different for each segment.

Storing values in an existing field

If a target field with the same name already exists for a document, values will be added to the end of the existing value list. It is possible to change this default behavior by supplying a PropertySetter.

Can be used both as a pre-parse or post-parse handler.

Examples

The example will expand a slash-separated vegetable hierarchy found in a "vegetable" field into a "vegetableHierarchy" field.

handler:
class: HierarchyTransformer
operations:
- fromField: vegetable
toField: vegetableHierarchy
fromSeparator: /

Usage

Full configuration skeleton, with every option and its default
class: HierarchyTransformer
label: string
operations:
- fromField: string
fromSeparator: string
keepEmptySegments: false
onSet: APPEND
regex: false
toField: string
toSeparator: string

Properties

PropertyTypeRequiredDefault
labelstringNo-
operationsHierarchyOperation[]No-

Property Details

label

An optional, user-supplied label for this step in the importer pipeline. It has no effect on processing — it exists purely to help identify this step, for example in large configurations or in the visual configurator.

operations

this work