If a property takes an object as its value, the document loader must convert that object to a string to include it in an output document. The PropertyFormatter interface defines two methods for performing this conversion: formatText() (for text properties) and formatMeta() (for meta properties).

By default, the document loaders use the implementation class atg.repository.search.indexing.formatter.PropertyFormatterImpl. For text properties, this class simply invokes the object’s toString() method. For meta properties, it invokes getLong() for numbers, getTime() for dates, and toString() for other objects.

You can write your own implementations of PropertyFormatter that use custom logic for performing the conversion. The simplest way to do this is to subclass PropertyFormatterImpl.

In the definition file, you can specify a custom property formatter by using the formatter attribute. For example, suppose you have a Nucleus component named /MyStuff/MyPropertyFormatter, of a custom class that implements the PropertyFormatter interface. You can specify it in the definition file like this:

<property name="price" formatter="/MyStuff/MyPropertyFormatter"/>

The value of the formatter attribute is the absolute path of the Nucleus component. To simplify coding of the definition file, you can map PropertyFormatter Nucleus components to simple names, and use those names as the values of formatter attributes. For example, if you map the /MyStuff/MyPropertyFormatter component to the name myFormatter, the above tag becomes:

<property name="price" formatter="myFormatter"/>

You can perform this mapping by setting the formatterMap property of the IndexingOutputConfig component. This property is a Map in which the keys are the names and the values are PropertyFormatter Nucleus components that the names represent.

 
loading table of contents...