You are here

public function SearchApiElasticsearchViewsHandlerArgumentMoreLikeThis::options_form in Search API Elasticsearch 7

Extend the options form a bit.

Overrides SearchApiViewsHandlerArgumentMoreLikeThis::options_form

File

includes/views/SearchApiElasticsearchViewsHandlerArgumentMoreLikeThis.inc, line 17
Contains SearchApiElasticsearchViewsHandlerArgumentMoreLikeThis.

Class

SearchApiElasticsearchViewsHandlerArgumentMoreLikeThis
@file Contains SearchApiElasticsearchViewsHandlerArgumentMoreLikeThis.

Code

public function options_form(&$form, &$form_state) {
  parent::options_form($form, $form_state);

  // We only want this to work with Elasticsearch servers.
  $index_name = substr($form_state['view']->base_table, 17);
  $query = new EntityFieldQuery();
  $query
    ->entityCondition('entity_type', 'search_api_index', '=');
  $query
    ->propertyCondition('machine_name', $index_name, '=');
  $result = $query
    ->execute();
  $result = reset(reset($result));
  $index = search_api_index_load($result->id);
  $server = $index
    ->server();
  $service_info = search_api_get_service_info();
  $reflection = new ReflectionClass($service_info[$server->class]['class']);
  if ($reflection
    ->isSubclassOf('SearchApiElasticsearchAbstractService')) {
    $form['min_doc_freq'] = array(
      '#type' => 'textfield',
      '#title' => t('Min doc frequency'),
      '#default_value' => $this->options['min_doc_freq'],
      '#element_validate' => array(
        'element_validate_integer_positive',
      ),
      '#description' => t('The frequency at which words will be ignored which do not occur in at least this many docs.'),
    );
    $form['min_term_freq'] = array(
      '#type' => 'textfield',
      '#title' => t('Min term frequency'),
      '#default_value' => $this->options['min_term_freq'],
      '#element_validate' => array(
        'element_validate_integer_positive',
      ),
      '#description' => t('The frequency below which terms will be ignored in the source doc.'),
    );
  }
}