org.compass.annotations
Annotation Type SearchableProperty


@Target(value={METHOD,FIELD})
@Retention(value=RUNTIME)
public @interface SearchableProperty

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 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 converter(). The specialized converter will implement the Converter interface, usually extending the 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 Collection type field/property, supporting either List or Set. The searchable property will try and automatically identify the element type using generics, but if the collection is not defined with generics, type() should be used to hint for the collection element type.

The searchable property can annotate an array/collections 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 managedId() and managedIdIndex().

Author:
kimchy

Optional Element Summary
 String accessor
          The property accessor that will be fetch and write the property value.
 String analyzer
          The analyzer of the auto generated SearchableMetaData.
 float boost
          The boost of the auto generated SearchableMetaData.
 String converter
          The converter of the auto generated SearchableMetaData.
 ExcludeFromAll excludeFromAll
          The exclude from all of the auto generated SearchableMetaData.
 String format
          The format of the auto generated SearchableMetaData.
 Index index
          The index of the auto generated SearchableMetaData.
 ManagedId managedId
          Controls if the internal meta-data id creation.
 ManagedIdIndex managedIdIndex
          If the internal meta-data id is created, controls it's index parameter.
 String name
          The name of the auto generated SearchableMetaData.
 String nullValue
          A null value to use to store in the index when the property has a null value.
 OmitNorms omitNorms
          The omitNorms of the auto generated SearchableMetaData.
 OmitTf omitTf
          The omitTf of the auto generated SearchableMetaData.
 boolean override
          If there is already an existing id with the same field/property name defined, will override it.
 String propertyConverter
          Converter that will apply to the property mapping.
 Reverse reverse
          The reverse of the auto generated SearchableMetaData.
 SpellCheck spellCheck
          Should this propety be included in the spell check index.
 Store store
          The store of the auto generated SearchableMetaData.
 TermVector termVector
          The termVector of the auto generated SearchableMetaData.
 Class type
          The class type of the property.
 

managedId

public abstract ManagedId managedId
Controls if the internal meta-data id creation.

Default:
NA

managedIdIndex

public abstract ManagedIdIndex managedIdIndex
If the internal meta-data id is created, controls it's index parameter.

Default:
NA

type

public abstract Class type
The class type of the property. Mainly used for Collection properties, without specific Generic type parameter.

Default:
java.lang.Object.class

override

public abstract boolean override
If there is already an existing id with the same field/property name defined, will override it.

Default:
true

propertyConverter

public abstract String propertyConverter
Converter that will apply to the property mapping. Not the generated meta-data.

Default:
""

accessor

public abstract String accessor
The property accessor that will be fetch and write the property value.

It is automatically set based on where the annotation is used, but can be explicitly set. Compass also supports custom property accessors, registered under a custom name, which can then be used here as well.

Default:
""

name

public abstract String name
The name of the auto generated SearchableMetaData. Maps to SearchableMetaData.name(). If no value is defined, will default to the class field/property name.

The meta-data will NOT be auto generated if the field/property have SearchableMetaData/SearchableMetaDatas AND the name() is not set.

Default:
""

boost

public abstract float boost
The boost of the auto generated SearchableMetaData. Maps to SearchableMetaData.boost().

The meta-data will NOT be auto generated if the field/property have SearchableMetaData/SearchableMetaDatas AND the name() is not set.

Default:
1.0f

store

public abstract Store store
The store of the auto generated SearchableMetaData. Maps to SearchableMetaData.store().

The meta-data will NOT be auto generated if the field/property have SearchableMetaData/SearchableMetaDatas AND the name() is not set.

Default:
NA

index

public abstract Index index
The index of the auto generated SearchableMetaData. Maps to SearchableMetaData.index().

The meta-data will NOT be auto generated if the field/property have SearchableMetaData/SearchableMetaDatas AND the name() is not set.

Default:
NA

termVector

public abstract TermVector termVector
The termVector of the auto generated SearchableMetaData. Maps to SearchableMetaData.termVector().

The meta-data will NOT be auto generated if the field/property have SearchableMetaData/SearchableMetaDatas AND the name() is not set.

Default:
NA

omitNorms

public abstract OmitNorms omitNorms
The omitNorms of the auto generated SearchableMetaData. Maps to SearchableMetaData.omitNorms().

The meta-data will NOT be auto generated if the field/property have SearchableMetaData/SearchableMetaDatas AND the name() is not set.

Default:
NA

omitTf

public abstract OmitTf omitTf
The omitTf of the auto generated SearchableMetaData. Maps to SearchableMetaData.omitTf().

The meta-data will NOT be auto generated if the field/property have SearchableMetaData/SearchableMetaDatas AND the name() is not set.

Default:
NA

reverse

public abstract Reverse reverse
The reverse of the auto generated SearchableMetaData. Maps to SearchableMetaData.reverse().

The meta-data will NOT be auto generated if the field/property have SearchableMetaData/SearchableMetaDatas AND the name() is not set.

Default:
NO

analyzer

public abstract String analyzer
The analyzer of the auto generated SearchableMetaData. Maps to SearchableMetaData.analyzer().

The meta-data will NOT be auto generated if the field/property have SearchableMetaData/SearchableMetaDatas AND the name() is not set.

Default:
""

excludeFromAll

public abstract ExcludeFromAll excludeFromAll
The exclude from all of the auto generated SearchableMetaData. Maps to SearchableMetaData.excludeFromAll().

The meta-data will NOT be auto generated if the field/property have SearchableMetaData/SearchableMetaDatas AND the name() is not set.

Default:
NO

converter

public abstract String converter
The converter of the auto generated SearchableMetaData. Maps to SearchableMetaData.converter(). The meta-data will be auto generated only if the name has a value.

This converter will also be used for an internal meta-data id (if required to be generated).

Default:
""

format

public abstract String format
The format of the auto generated SearchableMetaData. Maps to SearchableMetaData.format(). The meta-data will be auto generated only if the name has a value.

This format will also be used for an internal meta-data id (if required to be generated).

Default:
""

nullValue

public abstract String nullValue
A null value to use to store in the index when the property has a null value. Defaults to not storing null values if the globabl setting of compass.mapping.nullvalue is not set. If it set, disabling the null value can be done by setting it to CompassEnvironment.NullValue.DISABLE_NULL_VALUE_FOR_MAPPING value ($disable$).

Default:
""

spellCheck

public abstract SpellCheck spellCheck
Should this propety be included in the spell check index.

Note, most times this is not requried to be configured, since by default, the spell check index uses the "all" property.

Default:
EXCLUDE


Copyright (c) 2004-2009 The Compass Project.