public function PluginController_TagSearch_Create($Sender, $q, $id = false) {
      
      // Allow per-category tags
      $CategorySearch = C('Plugins.Tagging.CategorySearch', FALSE);
      if ($CategorySearch)
         $CategoryID = GetIncomingValue('CategoryID');
      
      $Query = $q;
      $Data = array();
      $Database = Gdn::Database();
      if ($Query) {
         $Test = Gdn::SQL()->Limit(1)->Get('Tag')->FirstRow(DATASET_TYPE_ARRAY);
         if (isset($Test['Type'])) {
            Gdn::SQL()->Where("nullif(Type, '') is null"); // Other UIs can set a different type
         }
         
         $TagQuery = Gdn::SQL()
            ->Select('TagID, Name')
            ->From('Tag')
            ->Like('Name', str_replace(array('%', '_'), array('\%', '_'), $Query), strlen($Query) > 2 ? 'both' : 'right')
            ->Limit(20);
         
         // Allow per-category tags
         if ($CategorySearch)
            $TagQuery->Where('CategoryID', $CategoryID);
         
         // Run tag search query
         $TagData = $TagQuery->Get();
         
         foreach ($TagData as $Tag) {
            $Data[] = array('id' => $id ? $Tag->TagID : $Tag->Name, 'name' => $Tag->Name);
         }
      }
      // Close the db before exiting.
      $Database->CloseConnection();
      // Return the data
      header("Content-type: application/json");
      echo json_encode($Data);
      exit();
   }