You are here

function hook_search_api_data_type_info in Search API 7

Define new data types for indexed properties.

New data types will appear as new option for the „Type“ field on indexes' „Fields“ tabs. Whether choosing a custom data type will have any effect depends on the server on which the data is indexed.

Return value

array An array containing custom data type definitions, keyed by their type identifier and containing the following keys:

  • name: The human-readable name of the type.
  • fallback: (optional) One of the default data types (the keys from search_api_default_field_types()) which should be used as a fallback if the server doesn't support this data type. Defaults to "string".
  • conversion callback: (optional) If specified, a callback function for converting raw values to the given type, if possible. For the contract of such a callback, see example_data_type_conversion().

See also

hook_search_api_data_type_info_alter()

search_api_get_data_type_info()

example_data_type_conversion()

1 invocation of hook_search_api_data_type_info()
search_api_get_data_type_info in ./search_api.module
Returns either all custom field type definitions, or a specific one.

File

./search_api.api.php, line 168
Hooks provided by the Search API module.

Code

function hook_search_api_data_type_info() {
  return array(
    'example_type' => array(
      'name' => t('Example type'),
      // Could be omitted, as "string" is the default.
      'fallback' => 'string',
      'conversion callback' => 'example_data_type_conversion',
    ),
  );
}