Enable the Users module for FTS

Matthew Marum —  June 17, 2013 — 1 Comment

If you are using a commercial version Sugar 6.5, you probably are taking advantage of the improved search ability thanks to the inclusion of elasticsearch. But one wrinkle that a customer of ours found out about is that the Users module isn’t properly able to be searched using the elasticsearch full text search ( FTS ) engine out of the box. But thanks to Simon Chapman and Harald Kuske, we have an easy fix for this.

Look in the file include/SugarSearchEngine/SugarSearchEngineIndexerBase.php and the function generateFTSQuery. You’ll see a line like this…

$selectFields = array($id,'team_id','team_set_id');

This causes an SQL error when you enable FTS for the Users module. To fix, change it to this…

If ($module == "Users") {
        $selectFields = array($id,'default_team team_id','team_set_id');
} Else {
        $selectFields = array($id,'team_id','team_set_id');

This isn’t an upgrade-safe fix however, so you’ll need to patch this file on every upgrade.

Matthew Marum


Matt is the Lead Developer Advocate for SugarCRM Engineering. Previously he was an Engineer on Sugar 7 and a Solutions Architect for the OEM program. He is also an avid trail runner, Boston Marathon qualifier and a karaoke aficionado.

One response to Enable the Users module for FTS

    Sebastian Marek June 17, 2013 at 6:48 am

    This will not work with Sugar 6.5.

    First of all the file that you need to change is: include/SugarSearchEngine/SugarSearchEngineFullIndexer.php.

    Secondly, the modules that are affected are Users and Employees (as Employees inherit some of the Users module functionality/definitions).

    Thirdly, selected fields are incorrect in the above snippet. The patch should be like this:

    // Non upgrade safe change to make ElasticSearch work for Users module
    if ($module == “Users” || $module == “Employees”) {
    $selectFields = array(‘id’,’default_team’,’team_set_id’);
    } else {
    $selectFields = array(‘id’,’team_id’,’team_set_id’);

    and finally, I think it’s not the best way of fixing this, as if you have any more modules that do not have team_id field it will break for them too. So you have to be careful with this.

    Is there a bug raised for this?

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s