Posted by robertDouglass on February 8, 2009 at 10:24pm
Jump to:
| Project: | Webmail Plus |
| Version: | 6.x-1.x-dev |
| Component: | Code |
| Category: | bug report |
| Priority: | normal |
| Assigned: | Unassigned |
| Status: | active |
| Issue tags: | ApacheSolr |
Issue Summary
<?php
$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. <a href="http://domain:8280/solr'" title="http://domain:8280/solr'" rel="nofollow">http://domain:8280/solr'</a>)
);
?>The ApacheSolr module has an API for handling connections. It can handle multiple connections.
<?php
/**
* 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
#1