You are here

class DrupalApacheSolrMultilingualService in Apache Solr Multilingual 6.3

Same name and namespace in other branches
  1. 7 DrupalApacheSolrMultilingualService.php \DrupalApacheSolrMultilingualService

Class DrupalApacheSolrMultilingualService extends DrupalApacheSolrService and overrides the internal method _makeHttpRequest to deal with multilingual spell checking.

Hierarchy

Expanded class hierarchy of DrupalApacheSolrMultilingualService

1 string reference to 'DrupalApacheSolrMultilingualService'
apachesolr_multilingual_enable in ./apachesolr_multilingual.install
Implements hook_enable().

File

./DrupalApacheSolrMultilingualService.php, line 10

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;
    }

    // Add our default params. This does not override our existing values
    $options += array(
      'headers' => array(),
      'method' => 'GET',
      'data' => NULL,
    );
    $result = drupal_http_request($url, $options['headers'], $options['method'], $options['data']);
    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

Namesort descending Modifiers Type Description Overrides
DrupalApacheSolrMultilingualService::_makeHttpRequest protected function Central method for making the actual http request to the Solr Server Overrides DrupalApacheSolrService::_makeHttpRequest
DrupalApacheSolrService::$env_id protected property
DrupalApacheSolrService::$luke protected property
DrupalApacheSolrService::$parsed_url protected property Server url
DrupalApacheSolrService::$soft_commit protected property Flag that denotes whether to use soft commits for Solr 4.x, defaults to FALSE.
DrupalApacheSolrService::$stats protected property
DrupalApacheSolrService::$system_info protected property
DrupalApacheSolrService::$update_url protected property Constructed servlet full path URLs
DrupalApacheSolrService::$_defaultTimeout protected property Default HTTP timeout when one is not specified (initialized to default_socket_timeout ini setting)
DrupalApacheSolrService::addDocuments public function Add an array of Solr Documents to the index all at once Overrides DrupalApacheSolrServiceInterface::addDocuments
DrupalApacheSolrService::checkResponse protected function Check the reponse code and thow an exception if it's not 200.
DrupalApacheSolrService::clearCache public function Clear cached Solr data. Overrides DrupalApacheSolrServiceInterface::clearCache
DrupalApacheSolrService::commit public function Send a commit command. Will be synchronous unless both wait parameters are set to false. Overrides DrupalApacheSolrServiceInterface::commit
DrupalApacheSolrService::deleteById public function Create a delete document based on document ID Overrides DrupalApacheSolrServiceInterface::deleteById
DrupalApacheSolrService::deleteByMultipleIds public function Create and post a delete document based on multiple document IDs. Overrides DrupalApacheSolrServiceInterface::deleteByMultipleIds
DrupalApacheSolrService::deleteByQuery public function Create a delete document based on a query and submit it Overrides DrupalApacheSolrServiceInterface::deleteByQuery
DrupalApacheSolrService::drupal_apachesolr_hash_base64 private function
DrupalApacheSolrService::escape public static function Escape a value for special query characters such as ':', '(', ')', '*', '?', etc.
DrupalApacheSolrService::escapePhrase public static function Escape a value meant to be contained in a phrase for special query characters
DrupalApacheSolrService::getFields public function Get just the field meta-data about the index. Overrides DrupalApacheSolrServiceInterface::getFields
DrupalApacheSolrService::getId function Overrides DrupalApacheSolrServiceInterface::getId
DrupalApacheSolrService::getLuke public function Get meta-data about the index. Overrides DrupalApacheSolrServiceInterface::getLuke
DrupalApacheSolrService::getSoftCommit public function Returns the flag that denotes whether to use soft commits for Solr 4.x.
DrupalApacheSolrService::getSolrVersion public function
DrupalApacheSolrService::getStats public function Get information about the Solr Core. Overrides DrupalApacheSolrServiceInterface::getStats
DrupalApacheSolrService::getStatsSummary public function Get summary information about the Solr Core. Overrides DrupalApacheSolrServiceInterface::getStatsSummary
DrupalApacheSolrService::getSystemInfo public function Get information about the Solr Core. Overrides DrupalApacheSolrServiceInterface::getSystemInfo
DrupalApacheSolrService::getUrl public function Get the Solr url Overrides DrupalApacheSolrServiceInterface::getUrl
DrupalApacheSolrService::httpBuildQuery protected function Like PHP's built in http_build_query(), but uses rawurlencode() and no [] for repeated params.
DrupalApacheSolrService::LUKE_SERVLET constant
DrupalApacheSolrService::makeServletRequest public function Make a request to a servlet (a path) that's not a standard path. Overrides DrupalApacheSolrServiceInterface::makeServletRequest
DrupalApacheSolrService::NAMED_LIST_FORMAT constant How NamedLists should be formatted in the output. This specifically effects facet counts. Valid values are 'map' (default) or 'flat'.
DrupalApacheSolrService::optimize public function Send an optimize command. Will be synchronous unless both wait parameters are set to false. Overrides DrupalApacheSolrServiceInterface::optimize
DrupalApacheSolrService::phrase public static function Convenience function for creating phrase syntax from a value
DrupalApacheSolrService::ping public function Call the /admin/ping servlet, to test the connection to the server. Overrides DrupalApacheSolrServiceInterface::ping
DrupalApacheSolrService::PING_SERVLET constant Servlet mappings
DrupalApacheSolrService::search public function Simple Search interface Overrides DrupalApacheSolrServiceInterface::search
DrupalApacheSolrService::SEARCH_SERVLET constant
DrupalApacheSolrService::setLuke protected function Sets $this->luke with the meta-data about the index from admin/luke.
DrupalApacheSolrService::setSoftCommit public function Flags whether to use soft commits for Solr 4.x.
DrupalApacheSolrService::setStats protected function Sets $this->stats with the information about the Solr Core form
DrupalApacheSolrService::setSystemInfo protected function Call the /admin/system servlet
DrupalApacheSolrService::setUrl public function Set the Solr url. Overrides DrupalApacheSolrServiceInterface::setUrl
DrupalApacheSolrService::STATS_SERVLET constant
DrupalApacheSolrService::STATS_SERVLET_4 constant
DrupalApacheSolrService::SYSTEM_SERVLET constant
DrupalApacheSolrService::update 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::update
DrupalApacheSolrService::UPDATE_SERVLET constant
DrupalApacheSolrService::_clearCache protected function
DrupalApacheSolrService::_constructUrl protected function Return a valid http URL given this server's host, port and path and a provided servlet name
DrupalApacheSolrService::_sendRawGet protected function Central method for making a GET operation against this Solr Server
DrupalApacheSolrService::_sendRawPost protected function Central method for making a POST operation against this Solr Server
DrupalApacheSolrService::__construct public function Constructor Overrides DrupalApacheSolrServiceInterface::__construct