$form['solr']['webmail_plus_solr_url'] = array(
	 '#type' => 'textfield',
	 '#title' => t('Solr URL'),
	 '#default_value' => variable_get('webmail_plus_solr_url', NULL),
	 '#description' => t('Specify the URL to the custom Webmail Plus Solr index, e.g. http://domain:8280/solr')
	);

The ApacheSolr module has an API for handling connections. It can handle multiple connections.


/**
 * Factory method for solr singleton object. Structure allows for an arbitrary
 * number of solr objects to be used based on the host, port, path combination.
 * Get an instance like this:
 *   $solr = apachesolr_get_solr();
 */
function apachesolr_get_solr($host = NULL, $port = NULL, $path = NULL) {
  static $solr_cache;

  if (empty($host)) {
    $host = variable_get('apachesolr_host', 'localhost');
  }
  if (empty($port)) {
    $port = variable_get('apachesolr_port', '8983');
  }
  if (empty($path)) {
    $path = variable_get('apachesolr_path', '/solr');
  }

  if (empty($solr_cache[$host][$port][$path])) {
    list($module, $filepath, $class) = variable_get('apachesolr_service_class', array('apachesolr', 'Drupal_Apache_Solr_Service.php', 'Drupal_Apache_Solr_Service'));
    include_once(drupal_get_path('module', $module) .'/'. $filepath);
    try {
      $solr_cache[$host][$port][$path] = new $class($host, $port, $path);
    }
    catch (Exception $e) {
      watchdog('Apache Solr', $e->getMessage(), NULL, WATCHDOG_ERROR);
      return;
    }
  }
  return $solr_cache[$host][$port][$path];
}

Comments

robertdouglass’s picture

Issue tags: +ApacheSolr