public function logSearch($term, $results, $time, $engine, $pageID) {

		// Make sure the search analytics are enabled.

		if(!Config::inst()->get(ExtensibleSearch::class, 'enable_analytics')) {
			return null;
		}

		// Log the details of the user search.

		$search = ExtensibleSearch::create(
			array(
				'Term'	=> $term,
				'Results' => $results,
				'Time' => $time,
				'SearchEngine' => $engine,
				'ExtensibleSearchPageID' => $pageID
			)
		);
		$search->write();

		// Log the details of the user search as a suggestion.

		if($results > 0) {
			$this->logSuggestion($term, $pageID);
		}
		return $search;
	}