class DrupalApacheSolrMultilingualService in Apache Solr Multilingual 7
Same name and namespace in other branches
- 6.3 DrupalApacheSolrMultilingualService.php \DrupalApacheSolrMultilingualService
Class DrupalApacheSolrMultilingualService extends DrupalApacheSolrService and overrides the internal method _makeHttpRequest to deal with multilingual spell checking.
Hierarchy
- class \DrupalApacheSolrService implements DrupalApacheSolrServiceInterface
Expanded class hierarchy of DrupalApacheSolrMultilingualService
2 string references to 'DrupalApacheSolrMultilingualService'
- apachesolr_multilingual_enable in ./
apachesolr_multilingual.install - Implements hook_enable().
- apachesolr_multilingual_update_7101 in ./
apachesolr_multilingual.install - Set variable "apachesolr_service_class" to "DrupalApacheSolrMultilingualService" to support multilingual spell checking.
File
- ./
DrupalApacheSolrMultilingualService.php, line 8
View source
class DrupalApacheSolrMultilingualService extends DrupalApacheSolrService {
/**
* Central method for making the actual http request to the Solr Server
*
* This is just a wrapper around drupal_http_request().
*/
protected function _makeHttpRequest($url, array $options = array()) {
if (!isset($options['method']) || $options['method'] == 'GET' || $options['method'] == 'HEAD') {
// Make sure we are not sending a request body.
$options['data'] = NULL;
}
// Default timeout of 30s is insufficient for luke requests and indexing.
$options += array(
'timeout' => variable_get('apachesolr_connection_timeout', '600.0'),
);
$result = drupal_http_request($url, $options);
if (!isset($result->code) || $result->code < 0) {
$result->code = 0;
$result->status_message = 'Request failed';
$result->protocol = 'HTTP/1.0';
}
// Additional information may be in the error property.
if (isset($result->error)) {
$result->status_message .= ': ' . check_plain($result->error);
}
if (!isset($result->data)) {
$result->data = '';
$result->response = NULL;
}
else {
// @see http://wiki.apache.org/solr/SolJSON
// "Using a JSON object (essentially a map or hash) for a NamedList results
// in the loss of some information."
// That's the reason why the multiple language specific spell check results
// get lost during json_decode(), because they are all named "spellcheck".
// Therefor we rename the the language specific spell checks.
// The language unspecific spellcheck is the last one in the list
// and therefor not touched.
$language_ids = array_keys(apachesolr_multilingual_language_list());
foreach ($language_ids as $language_id) {
$result->data = preg_replace('@"spellcheck"@', '"spellcheck_' . $language_id . '"', $result->data, 1);
}
$response = json_decode($result->data);
if (is_object($response)) {
foreach ($response as $key => $value) {
$result->{$key} = $value;
}
}
}
return $result;
}
}
Members
Name | Modifiers | Type | Description | Overrides |
---|---|---|---|---|
DrupalApacheSolrMultilingualService:: |
protected | function |
Central method for making the actual http request to the Solr Server Overrides DrupalApacheSolrService:: |
|
DrupalApacheSolrService:: |
protected | property | ||
DrupalApacheSolrService:: |
protected | property | ||
DrupalApacheSolrService:: |
protected | property | Server url | |
DrupalApacheSolrService:: |
protected | property | Flag that denotes whether to use soft commits for Solr 4.x, defaults to FALSE. | |
DrupalApacheSolrService:: |
protected | property | ||
DrupalApacheSolrService:: |
protected | property | ||
DrupalApacheSolrService:: |
protected | property | Constructed servlet full path URLs | |
DrupalApacheSolrService:: |
protected | property | Default HTTP timeout when one is not specified (initialized to default_socket_timeout ini setting) | |
DrupalApacheSolrService:: |
public | function |
Add an array of Solr Documents to the index all at once Overrides DrupalApacheSolrServiceInterface:: |
|
DrupalApacheSolrService:: |
protected | function | Check the reponse code and thow an exception if it's not 200. | |
DrupalApacheSolrService:: |
public | function |
Clear cached Solr data. Overrides DrupalApacheSolrServiceInterface:: |
|
DrupalApacheSolrService:: |
public | function |
Send a commit command. Will be synchronous unless both wait parameters are set to false. Overrides DrupalApacheSolrServiceInterface:: |
|
DrupalApacheSolrService:: |
public | function |
Create a delete document based on document ID Overrides DrupalApacheSolrServiceInterface:: |
|
DrupalApacheSolrService:: |
public | function |
Create and post a delete document based on multiple document IDs. Overrides DrupalApacheSolrServiceInterface:: |
|
DrupalApacheSolrService:: |
public | function |
Create a delete document based on a query and submit it Overrides DrupalApacheSolrServiceInterface:: |
|
DrupalApacheSolrService:: |
public static | function | Escape a value for special query characters such as ':', '(', ')', '*', '?', etc. | |
DrupalApacheSolrService:: |
public static | function | Escape a value meant to be contained in a phrase for special query characters | |
DrupalApacheSolrService:: |
public | function | Determine the routine that called this query. | |
DrupalApacheSolrService:: |
public | function |
Get just the field meta-data about the index. Overrides DrupalApacheSolrServiceInterface:: |
|
DrupalApacheSolrService:: |
function |
Overrides DrupalApacheSolrServiceInterface:: |
||
DrupalApacheSolrService:: |
public | function |
Get meta-data about the index. Overrides DrupalApacheSolrServiceInterface:: |
|
DrupalApacheSolrService:: |
public | function | Returns the flag that denotes whether to use soft commits for Solr 4.x. | |
DrupalApacheSolrService:: |
public | function |
Get the current solr version. This could be 1, 3 or 4 Overrides DrupalApacheSolrServiceInterface:: |
|
DrupalApacheSolrService:: |
public | function |
Get information about the Solr Core. Overrides DrupalApacheSolrServiceInterface:: |
|
DrupalApacheSolrService:: |
public | function |
Get summary information about the Solr Core. Overrides DrupalApacheSolrServiceInterface:: |
|
DrupalApacheSolrService:: |
public | function |
Get information about the Solr Core. Overrides DrupalApacheSolrServiceInterface:: |
|
DrupalApacheSolrService:: |
public | function |
Get the Solr url Overrides DrupalApacheSolrServiceInterface:: |
|
DrupalApacheSolrService:: |
protected | function | Like PHP's built in http_build_query(), but uses rawurlencode() and no [] for repeated params. | |
DrupalApacheSolrService:: |
constant | |||
DrupalApacheSolrService:: |
public | function |
Make a request to a servlet (a path) that's not a standard path. Overrides DrupalApacheSolrServiceInterface:: |
|
DrupalApacheSolrService:: |
constant | How NamedLists should be formatted in the output. This specifically effects facet counts. Valid values are 'map' (default) or 'flat'. | ||
DrupalApacheSolrService:: |
public | function |
Send an optimize command. Will be synchronous unless both wait parameters are set
to false. Overrides DrupalApacheSolrServiceInterface:: |
|
DrupalApacheSolrService:: |
public static | function | Convenience function for creating phrase syntax from a value | |
DrupalApacheSolrService:: |
public | function |
Call the /admin/ping servlet, to test the connection to the server. Overrides DrupalApacheSolrServiceInterface:: |
|
DrupalApacheSolrService:: |
constant | Servlet mappings | ||
DrupalApacheSolrService:: |
public | function |
Simple Search interface Overrides DrupalApacheSolrServiceInterface:: |
|
DrupalApacheSolrService:: |
constant | |||
DrupalApacheSolrService:: |
protected | function | Sets $this->luke with the meta-data about the index from admin/luke. | |
DrupalApacheSolrService:: |
public | function | Flags whether to use soft commits for Solr 4.x. | |
DrupalApacheSolrService:: |
protected | function | Sets $this->stats with the information about the Solr Core form | |
DrupalApacheSolrService:: |
protected | function | Call the /admin/system servlet | |
DrupalApacheSolrService:: |
public | function |
Set the Solr url. Overrides DrupalApacheSolrServiceInterface:: |
|
DrupalApacheSolrService:: |
constant | |||
DrupalApacheSolrService:: |
constant | |||
DrupalApacheSolrService:: |
constant | |||
DrupalApacheSolrService:: |
public | function |
Raw update Method. Takes a raw post body and sends it to the update service. Post body
should be a complete and well formed xml document. Overrides DrupalApacheSolrServiceInterface:: |
|
DrupalApacheSolrService:: |
constant | |||
DrupalApacheSolrService:: |
protected | function | ||
DrupalApacheSolrService:: |
protected | function | Return a valid http URL given this server's host, port and path and a provided servlet name | |
DrupalApacheSolrService:: |
protected | function | Central method for making a GET operation against this Solr Server | |
DrupalApacheSolrService:: |
protected | function | Central method for making a POST operation against this Solr Server | |
DrupalApacheSolrService:: |
public | function |
Constructor Overrides DrupalApacheSolrServiceInterface:: |