You are here

function search_api_install in Search API 7

Implements hook_install().

Creates a default node index if the module is installed manually.

File

./search_api.install, line 317
Install, update and uninstall functions for the Search API module.

Code

function search_api_install() {

  // In case the module is installed via an installation profile, a batch is
  // active and we skip that.
  if (batch_get()) {
    return;
  }
  $name = t('Default node index');
  $values = array(
    'name' => $name,
    'machine_name' => preg_replace('/[^a-z0-9]+/', '_', drupal_strtolower($name)),
    'description' => t('An automatically created search index for indexing node data. Might be configured to specific needs.'),
    'server' => NULL,
    'item_type' => 'node',
    'options' => array(
      'index_directly' => 1,
      'cron_limit' => '50',
      'data_alter_callbacks' => array(
        'search_api_alter_node_access' => array(
          'status' => 1,
          'weight' => '0',
          'settings' => array(),
        ),
      ),
      'processors' => array(
        'search_api_case_ignore' => array(
          'status' => 1,
          'weight' => '0',
          'settings' => array(
            'strings' => 0,
          ),
        ),
        'search_api_html_filter' => array(
          'status' => 1,
          'weight' => '10',
          'settings' => array(
            'title' => 0,
            'alt' => 1,
            'tags' => "h1 = 5\n" . "h2 = 3\n" . "h3 = 2\n" . "strong = 2\n" . "b = 2\n" . "em = 1.5\n" . "u = 1.5",
          ),
        ),
        'search_api_tokenizer' => array(
          'status' => 1,
          'weight' => '20',
          'settings' => array(
            'spaces' => '[^\\p{L}\\p{N}]',
            'ignorable' => '[-]',
          ),
        ),
      ),
      'fields' => array(
        'type' => array(
          'type' => 'string',
        ),
        'title' => array(
          'type' => 'text',
          'boost' => '5.0',
        ),
        'promote' => array(
          'type' => 'boolean',
        ),
        'sticky' => array(
          'type' => 'boolean',
        ),
        'created' => array(
          'type' => 'date',
        ),
        'changed' => array(
          'type' => 'date',
        ),
        'author' => array(
          'type' => 'integer',
          'entity_type' => 'user',
        ),
        'comment_count' => array(
          'type' => 'integer',
        ),
        'search_api_language' => array(
          'type' => 'string',
        ),
        'body:value' => array(
          'type' => 'text',
        ),
      ),
    ),
  );
  search_api_index_insert($values);
  drupal_set_message(t('The Search API module was installed. A new default node index was created.'));
}