You are here

function elasticsearch_connector_search_api_return_form_options in Elasticsearch Connector 7.5

Same name and namespace in other branches
  1. 7 modules/elasticsearch_connector_search_api/elasticsearch_connector_search_api.module \elasticsearch_connector_search_api_return_form_options()
  2. 7.2 modules/elasticsearch_connector_search_api/elasticsearch_connector_search_api.module \elasticsearch_connector_search_api_return_form_options()

The form options for add/edit index.

Parameters

array $form:

array $default_values:

1 call to elasticsearch_connector_search_api_return_form_options()
elasticsearch_connector_search_api_form_alter in modules/elasticsearch_connector_search_api/elasticsearch_connector_search_api.module
Implements hook_form_alter().

File

modules/elasticsearch_connector_search_api/elasticsearch_connector_search_api.module, line 214
Provides a elasticsearch-based service class for the Search API.

Code

function elasticsearch_connector_search_api_return_form_options(&$form, &$form_state, $default_values = array(), $flag) {
  global $databases;
  if (!isset($form_state['values'])) {
    $server = $form_state['index']
      ->server();
  }
  else {
    $server = search_api_server_load($form_state['values']['server']);
  }
  if (empty($server)) {
    watchdog('elasticsearch_connector_search_api', 'System cannot load the server.');
    return;
  }
  $cluster_id = elasticsearch_connector_get_default_connector();
  if (!empty($server->options['cluster'])) {
    $cluster_id = $server->options['cluster'];
  }
  $form['options']['index_name'] = array(
    '#type' => 'ec_index',
    '#title' => t('Select cluster'),
    '#required' => TRUE,
    '#cluster_id' => $cluster_id,
    '#default_value' => isset($default_values['index_name']['index']) ? $default_values['index_name'] : array(),
  );
  $form['options']['collect_index_statistics'] = array(
    '#type' => 'checkbox',
    '#title' => t('Collect index statistics'),
    '#default_value' => isset($default_values['collect_index_statistics']) ? $default_values['collect_index_statistics'] : 0,
    '#description' => t('Enable the statistics collection that will help you to better analys what the users are searching for.'),
  );
  $form['options']['log_only_not_found'] = array(
    '#type' => 'checkbox',
    '#title' => t('Log only the "Not found" results'),
    '#default_value' => isset($default_values['log_only_not_found']) ? $default_values['log_only_not_found'] : 0,
    '#description' => t('Log only the "Not found" results by skipping the rest.'),
  );
  $form['options']['index_statistics_num_of_shards'] = array(
    '#type' => 'textfield',
    '#title' => t('Number of shards for statistics index'),
    '#element_validate' => array(
      'element_validate_number',
    ),
    '#default_value' => isset($default_values['index_statistics_num_of_shards']) ? $default_values['index_statistics_num_of_shards'] : SearchApiElasticsearchConnectorStats::NUM_OF_SHARDS,
    '#description' => t('Enter the number of shards for the statistics index.'),
  );
  $form['options']['index_statistics_num_of_replicas'] = array(
    '#type' => 'textfield',
    '#title' => t('Number of replicas for statistics index'),
    '#element_validate' => array(
      'element_validate_number',
    ),
    '#default_value' => isset($default_values['index_statistics_num_of_replicas']) ? $default_values['index_statistics_num_of_replicas'] : SearchApiElasticsearchConnectorStats::NUM_OF_REPLICAS,
    '#description' => t('Enter the number of replicas for the statistics index.'),
  );
}