You are here

function apachesolr_realtime_commit in Apache Solr Real-Time 7

Commit Solr index making the document available.

2 calls to apachesolr_realtime_commit()
apachesolr_realtime_entity_delete in ./apachesolr_realtime.module
Implements hook_entity_delete().
apachesolr_realtime_index_now in ./apachesolr_realtime.module
Prepare entity as document for adding to Solr index.

File

./apachesolr_realtime.module, line 164
Module file for apachesolr_realtime

Code

function apachesolr_realtime_commit($env_id) {
  $server = apachesolr_environment_load($env_id);
  $solr_version = apachesolr_realtime_solrversion();
  $url = $server['url'] . "/update";

  // If Solr 4 perform softCommit.
  if ($solr_version == '4') {
    $url .= '?commit=true&softCommit=true';
  }
  else {
    $url .= '?commit=true';
  }
  $result = drupal_http_request($url);
  if ($result->code != 200 || !empty($result->error)) {
    $commit_time = date('r');
    watchdog('Apachesolr Realtime', 'Commit at %commit_time failed. Solr will commit at the next interval.', array(
      '%commit_time' => $commit_time,
    ), WATCHDOG_WARNING);
    drupal_set_message(t('Commit at @commit_time failed. Solr will commit at the next interval.', array(
      '@commit_time' => $commit_time,
    )), 'warning');
  }
}