You are here

public function StandardSolrCloudConnector::buildConfigurationForm in Search API Solr 4.x

Same name and namespace in other branches
  1. 8.3 src/Plugin/SolrConnector/StandardSolrCloudConnector.php \Drupal\search_api_solr\Plugin\SolrConnector\StandardSolrCloudConnector::buildConfigurationForm()
  2. 8.2 src/Plugin/SolrConnector/StandardSolrCloudConnector.php \Drupal\search_api_solr\Plugin\SolrConnector\StandardSolrCloudConnector::buildConfigurationForm()

Form constructor.

Plugin forms are embedded in other forms. In order to know where the plugin form is located in the parent form, #parents and #array_parents must be known, but these are not available during the initial build phase. In order to have these properties available when building the plugin form's elements, let this method return a form element that has a #process callback and build the rest of the form in the callback. By the time the callback is executed, the element's #parents and #array_parents properties will have been set by the form API. For more documentation on #parents and #array_parents, see \Drupal\Core\Render\Element\FormElement.

Parameters

array $form: An associative array containing the initial structure of the plugin form.

\Drupal\Core\Form\FormStateInterface $form_state: The current state of the form. Calling code should pass on a subform state created through \Drupal\Core\Form\SubformState::createForSubform().

Return value

array The form structure.

Overrides SolrConnectorPluginBase::buildConfigurationForm

File

src/Plugin/SolrConnector/StandardSolrCloudConnector.php, line 52

Class

StandardSolrCloudConnector
Standard Solr Cloud connector.

Namespace

Drupal\search_api_solr\Plugin\SolrConnector

Code

public function buildConfigurationForm(array $form, FormStateInterface $form_state) {
  $form = parent::buildConfigurationForm($form, $form_state);
  $form['host']['#title'] = $this
    ->t('Solr node');
  $form['host']['#description'] = $this
    ->t('The host name or IP of a Solr node, e.g. <code>localhost</code> or <code>www.example.com</code>.');
  $form['path']['#description'] = $this
    ->t('The path that identifies the Solr instance to use on the node.');
  $form['core']['#title'] = $this
    ->t('Default Solr collection');
  $form['core']['#description'] = $this
    ->t('The name that identifies the Solr default collection to use. The concrete collection to use could be overwritten per index.');
  $form['core']['#required'] = FALSE;
  $form['timeout']['#description'] = $this
    ->t('The timeout in seconds for search queries sent to the Solr collection.');
  $form['index_timeout']['#description'] = $this
    ->t('The timeout in seconds for indexing requests to the Solr collection.');
  $form['optimize_timeout']['#description'] = $this
    ->t('The timeout in seconds for background index optimization queries on the Solr collection.');
  $form['advanced']['checkpoints_collection'] = [
    '#type' => 'textfield',
    '#title' => $this
      ->t('checkpoints_collection'),
    '#description' => $this
      ->t("The collection where topic checkpoints are stored. Not required if you don't work with topic() streaming expressions."),
    '#default_value' => isset($this->configuration['checkpoints_collection']) ? $this->configuration['checkpoints_collection'] : '',
  ];
  $form['advanced']['stats_cache'] = [
    '#type' => 'select',
    '#title' => $this
      ->t('StatsCache'),
    '#options' => [
      'org.apache.solr.search.stats.LocalStatsCache' => 'LocalStatsCache',
      'org.apache.solr.search.stats.ExactStatsCache' => 'ExactStatsCache',
      'org.apache.solr.search.stats.ExactSharedStatsCache' => 'ExactSharedStatsCache',
      'org.apache.solr.search.stats.LRUStatsCache' => 'LRUStatsCache',
    ],
    '#description' => $this
      ->t('Document and term statistics are needed in order to calculate relevancy. Solr provides four implementations out of the box when it comes to document stats calculation. LocalStatsCache: This only uses local term and document statistics to compute relevance. In cases with uniform term distribution across shards, this works reasonably well. ExactStatsCache: This implementation uses global values (across the collection) for document frequency. ExactSharedStatsCache: This is exactly like the exact stats cache in its functionality but the global stats are reused for subsequent requests with the same terms. LRUStatsCache: This implementation uses an LRU cache to hold global stats, which are shared between requests. Formerly a limitation was that TF/IDF relevancy computations only used shard-local statistics. This is still the case by default or if LocalStatsCache is used. If your data isn’t randomly distributed, or if you want more exact statistics, then remember to configure the ExactStatsCache (or "better").'),
    '#default_value' => isset($this->configuration['stats_cache']) ? $this->configuration['stats_cache'] : 'org.apache.solr.search.stats.LRUStatsCache',
  ];
  $form['advanced']['distrib'] = [
    '#type' => 'checkbox',
    '#title' => $this
      ->t('Distribute queries'),
    '#description' => $this
      ->t("Normally queries should be distributed across all nodes of a Solr Cloud that store shards of the collection. In rare debug use-cases or when you only run a single node it might be useful to disable the query distribution."),
    '#default_value' => $this->configuration['distrib'] ?? TRUE,
  ];
  return $form;
}