You are here

protected function DrupalApacheSolrService::setLuke in Apache Solr Search 8

Same name and namespace in other branches
  1. 6.3 Drupal_Apache_Solr_Service.php \DrupalApacheSolrService::setLuke()
  2. 7 Drupal_Apache_Solr_Service.php \DrupalApacheSolrService::setLuke()

Sets $this->luke with the meta-data about the index from admin/luke.

1 call to DrupalApacheSolrService::setLuke()
DrupalApacheSolrService::getLuke in ./Drupal_Apache_Solr_Service.php
Get meta-data about the index.

File

./Drupal_Apache_Solr_Service.php, line 208

Class

DrupalApacheSolrService
Starting point for the Solr API. Represents a Solr server resource and has methods for pinging, adding, deleting, committing, optimizing and searching.

Code

protected function setLuke($num_terms = 0) {
  if (empty($this->luke[$num_terms])) {
    $params = array(
      'numTerms' => "{$num_terms}",
      'wt' => 'json',
      'json.nl' => self::NAMED_LIST_FORMAT,
    );
    $url = $this
      ->_constructUrl(self::LUKE_SERVLET, $params);
    if ($this->env_id) {
      $cid = $this->env_id . ":luke:" . drupal_hash_base64($url);
      $cache = cache_get($cid, 'cache_apachesolr');
      if (isset($cache->data)) {
        $this->luke = $cache->data;
      }
    }
  }

  // Second pass to populate the cache if necessary.
  if (empty($this->luke[$num_terms])) {
    $this->luke[$num_terms] = $this
      ->_sendRawGet($url);
    if ($this->env_id) {
      cache_set($cid, $this->luke, 'cache_apachesolr');
    }
  }
}