%d ) OR (n.created > %d OR n.changed > %d OR c.last_comment_timestamp > %d))', $change, $last, $change, $change, $change)); return array('remaining' => $remaining, 'total' => $total); case 'search': global $pager_total; // This is the object that does the communication with the solr server. $solr =& apachesolr_get_solr(variable_get('apachesolr_host', 'localhost'), variable_get('apachesolr_port', 8983), variable_get('apachesolr_path', '/solr')); // This is the object that knows about the query coming from the user. $query =& apachesolr_drupal_query($keys); try { $params = array( //'qt' => 'standard', 'fl' => '*,score', 'rows' => 10, 'facet' => 'true', 'facet.limit' => -1, 'facet.field' => array('tid', 'type', 'uid'), 'facet.mincount' => 1, 'facet.sort' => 'true', ); if ($fields = apachesolr_cck_fields()) { foreach ($fields as $name => $field) { $index_key = apachesolr_index_key($field); $params['facet.field'][] = $index_key; } } $params['start'] = $_GET['page'] * $params['rows']; $response = $solr->search($query->get_query(), $params['start'], $params['rows'], $params); $total = $response->numFound; // The response is cached so that it is accessible to the blocks and anything // else that needs it beyond the initial search. apachesolr_static_response_cache($response); pager_query("SELECT %d", 10, 0, NULL, $total); if ($total > 0) { static $users = array(); foreach ($response->documents as $doc) { if (empty($users[$doc->uid])) { $users[$doc->uid] = db_result(db_query("SELECT name FROM {users} WHERE uid = %d", $doc->uid)); } $doc->name = $users[$doc->uid]; $extra = node_invoke_nodeapi(&$doc, 'search result'); $extra['score'] = $doc->score; $snippet = search_excerpt($keys, $doc->body); if (trim($snippet) == '...') { $snippet = ''; } $results[] = array('link' => url('node/'. $doc->nid, NULL, NULL, TRUE), 'type' => node_get_types('name', $doc), 'title' => $doc->title, 'user' => theme('username', $doc), 'date' => $doc->changed, 'node' => $doc, 'extra' => $extra, 'score' => $doc->score, 'snippet' => $snippet); } } // Set breadcrumb drupal_set_breadcrumb($query->get_breadcrumb()); return $results; } // try catch (Exception $e) { watchdog('Apache Solr', $e->getMessage(), WATCHDOG_ERROR); } } // switch }