Specifies a searchable property on property or field of the
Searchable class.
The searchable property will automatically create a
SearchableMetaData ,
with its name being the field/property name. It will not be created if the
SearchableProperty.name() is not set AND there are either
SearchableMetaData or
SearchableMetaDatas annotating the class field/property. Most of
the attributes that can control the meta-data are provided in the searchable
property as well, they are marked in the java doc.
The searchable property/meta-data is meant to handle basic types (which usually translate to
a String saved in the search engine). The conversion is done using converters, with
Compass providing converters for most basic types. A specialized Converter can be
associated with the auto generated meta-data using
SearchableProperty.converter() . The
specialized converter will implement the
org.compass.core.converter.Converter interface, usually extending the
org.compass.core.converter.basic.AbstractBasicConverter .
Another way of defining a converter for a class can be done using the
SearchableClassConverter to annotate the class that needs conversion, with Compass auto detecting it.
Note, that most of the time, a specialized converter for user classes will not be needed,
since the
SearchableComponent usually makes more sense to use.
The searchable property can annotate a
java.util.Collection type field/property,
supporting either
java.util.List or
java.util.Set . The searchable property
will try and automatically identify the element type using generics, but if the collection
is not defined with generics,
SearchableProperty.type() should be used to hint for the collection
element type.
The searchable property can annotate an array as well, with the array element type used for
Converter lookups.
Compass might require an internal meta-data to be created, so it can identify the correct
value that match the property/field. Controlling the creation and specifics of the intenal
meta-data id can be done using
SearchableProperty.managedId() and
SearchableProperty.managedIdIndex() .
author: kimchy |