function elasticsearch_connector_search_api_return_form_options in Elasticsearch Connector 7.2
Same name and namespace in other branches
- 7.5 modules/elasticsearch_connector_search_api/elasticsearch_connector_search_api.module \elasticsearch_connector_search_api_return_form_options()
- 7 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 211 - 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_ttl'] = array(
'#type' => 'textfield',
'#title' => t('Statistics TTL interval'),
'#element_validate' => array(
'_elasticsearch_connector_validate_ttl_field',
),
'#default_value' => isset($default_values['index_statistics_ttl']) ? $default_values['index_statistics_ttl'] : SearchApiElasticsearchConnectorStats::TTL,
'#description' => t('Use format like 1d. Suffix can be d (days), m (minutes), h (hours), ms (milliseconds) or w (weeks).' . ' You can dynamically update the default interval.' . ' However it won\'t change the TTL of already indexed messages but will be used for future logs.'),
);
}