You are here

function apachesolr_drush_solr_search in Apache Solr Search 7

Same name and namespace in other branches
  1. 8 drush/apachesolr.drush.inc \apachesolr_drush_solr_search()
  2. 5.2 apachesolr.drush.inc \apachesolr_drush_solr_search()
  3. 6.3 drush/apachesolr.drush.inc \apachesolr_drush_solr_search()
  4. 6 drush/apachesolr.drush.inc \apachesolr_drush_solr_search()
  5. 6.2 drush/apachesolr.drush.inc \apachesolr_drush_solr_search()

Search the solr index using Drush

1 string reference to 'apachesolr_drush_solr_search'
apachesolr_drush_command in drush/apachesolr.drush.inc
Implements hook_drush_command().

File

drush/apachesolr.drush.inc, line 318
drush integration for apachesolr.

Code

function apachesolr_drush_solr_search() {
  $args = func_get_args();
  $keys = implode(' ', $args);
  foreach (apachesolr_search_search_execute($keys) as $result) {
    $output = $result['fields']['path'];
    if (isset($result['user']) && isset($result['node']->is_uid)) {
      $output .= ' ' . dt('by @name (user/@uid)', array(
        '@name' => strip_tags($result['user']),
        '@uid' => $result['node']->is_uid,
      ));
    }
    $output .= "\n";
    $output .= dt('title: ') . $result['title'] . "\n";
    $output .= trim(preg_replace('/\\s+/', ' ', strip_tags($result['snippet']))) . "\n\n";
    drush_print($output);
  }
}