Tearing my hair out with global search

I know there have been many many many posts about global search, but to be honest, I’m not sure what the heck is happening and why it seems very unreliable for me, and am hoping that someone can help me out.

I’m currently in the process of building up suiteCRM to essentially mirror salesforce, and have 95% of the work done, but am having a hell of a time getting the search to work properly.

issue 1 appears to be with the bugs section. The SQL Query that fires off to the database doesn’t seem to have a WHERE clause, so all 6000+ records are returned. I have

$dictionary['Bug']['fields']['record_id__c']['unified_search'] = true;

set in custom/modules/bugs/Ext/Vardefs/vardefs.ext.php, I also have

$dictionary['Bug'] = array('table' => 'bugs',    'audited'=>true, 'comment' => 'Bugs are defects in products and services','duplicate_merge'=>true
                               ,'unified_search' => true,'fields' => array ( 

in /modules/Bugs/vardefs, and finally I have

'record_id__c' =>
		array(
			'query_type' => 'default',
		),

in /custom/modules/Bugs/metadata/SearchFields.php

however still I get no where clause in the query

issue 2 is similar but with some custom modules.

I have 2 fields in one module… account_name__c and phone__c

both are set as ‘unified_search’ => true, in /modules//vardefs.php, and both are set as

 'xxxxx' => array( 'query_type' => 'default' ),

in /modules//metadata/SearchFields.php

I also have matching entries in /custom/modules//Ext/Vardefs/vardefs.ext.php and /custom/modules//metadata/SearchFields.php

I’ve done the repair/rebuild plenty of times as well as repairing relationships (cos I read that somewhere), and the Account_name__c search works but the phone doesn’t. the phone search doesn’t show up in the SQL Query, so it’s not a fact of having the wrong data entered in the search area.

is there some form of Cache that’s being used that I can just delete and rebuild? I’m not using AOD cos that seemed to give me unexpected results