public function logSuggestion($term, $pageID) {

		// Make sure the search matches the minimum autocomplete length.

		if(strlen($term) < 3) {
			return null;
		}

		// Make sure the suggestion doesn't already exist.

		$term = strtolower($term);
		$filter = array(
			'Term' => $term,
			'ExtensibleSearchPageID' => $pageID
		);
		$suggestion = ExtensibleSearchSuggestion::get()->filter($filter)->first();

		// Store the frequency to make search suggestion relevance more efficient.

		$frequency = ExtensibleSearch::get()->filter($filter)->count();
		if($suggestion) {
			$suggestion->Frequency = $frequency;
		}
		else {

			// Log the suggestion.

			$suggestion = ExtensibleSearchSuggestion::create(
				array(
					'Term' => $term,
					'Frequency' => $frequency,
					'Approved' => (int)Config::inst()->get(ExtensibleSearchSuggestion::class, 'automatic_approval'),
					'ExtensibleSearchPageID' => $pageID
				)
			);
		}

		// The suggestion might now exist.

		try {
			$suggestion->write();
		}
		catch(ValidationException $exception) {

			// This indicates a possible race condition.

			$suggestions = ExtensibleSearchSuggestion::get()->filter($filter);
			while($suggestions->count() > 1) {
				$suggestions->last()->delete();
			}
			$suggestion = $suggestions->first();
			$frequency = ExtensibleSearch::get()->filter($filter)->count();
			$suggestion->Frequency = $frequency;
			$suggestion->write();
		}
		return $suggestion;
	}