Customizing Elasticsearch analysis in Sugar 7.6

cedricmourizard —  August 31, 2015 — 5 Comments

Here is a guest post from a couple members of the Sugar Developer community.  Yann Berges and Cédric Mourizard from Synolia, an Elite SugarCRM Partner, share some insights on how to improve the quality of Elasticsearch results in Sugar.

Elasticsearch in Sugar 7

Since Sugar 6.5, Elasticsearch has been included as a core feature of the Sugar Application and became a required component in Sugar 7.x releases. You can find some information regarding installation, configuration, and monitoring of Elasticsearch in the Knowledge Base.

It works very well and is pretty fast!

However, the default configuration is often too strict with diacritics such as accent and stressed letters found in languages like French.  For example, the default configuration will not match e with é during a global search which is not desirable for us.

Search for

Search for “Saute” did not match “Sautéed”

Below we will explore how Elasticsearch Analyzers can be used to address this issue.  It is quite easy and does not require custom code!

To improve the global search with this type of capability you need to setup an Analyzer. Analyzers are how Elasticsearch generates tokens from input data to be indexed. You can also combine analyzers for multiple transformations; like converting text to lowercase, utilize a list of stopwords to exclude some words and lot of capabilities, or apply regular expressions.

Configuring Elasticsearch Analyzers in Sugar 7.6

One of the out of the box analyzers called asciifolding is for converting Unicode characters into lower ASCII, when they exist.  To add this type of configuration you could do that very easily with an entry in $sugar_config.

Add the following configuration setting to your config_override.php at the root of your Sugar 7.6 installation.  You may need to create this PHP file if it doesn’t exist already.  The significant part is the line where the ‘asciifolding’ filter is added.

After updating your config, you need to do a Quick Repair & Rebuild and perform a full system index which will rebuild the index data using this new additional analyzer.

Now if one of your modules contains, for example, cooking recipes then you can now search “Saute” and find the right results with or without accents like “Sautéed Tuna Steaks”

Search for “Saute” matching “Sautéed”

Search for “Saute” matching “Sautéed”

Enjoy your (Elastic)search!

5 responses to Customizing Elasticsearch analysis in Sugar 7.6

  1. 

    The gist on github needs a login – I can’t access this. Please fix this

  2. 

    Still I have the same problem.

Trackbacks and Pingbacks:

  1. SugarCRM – Ignorer les accents dans la recherche globale de Sugar 7 – SynoLab - July 26, 2016

    […] Un article plus détaillé est accessible directement sur le Blog de SugarCRM : https://developer.sugarcrm.com/2015/08/31/improving-your-elasticsearch-analysis-in-sugar-7/ […]

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