Install Elasticsearch On CentOS 6.5

Introduction

While setting up a new instance of SugarCRM 7.1 I reached a point in which Elasticsearch is required to continue. This is a very welcomed surprise! For those of you not familiar with full text search in SugarCRM, it offers the following benefits.

  • Full text search on keywords or partial words
  • Quick View previews search results with the search string highlighted
  • Prioritized results are shown first for the module from which the search is performed, followed by results from other modules
  • Wildcard searches
  • Include a field name in searches to filter results by matches to that field only
  • Show All link displays the full search results from each module in separate panels

Installation

While Googling I noticed a common theme of making installation way more difficult than it needed to be. Many tutorials have you install Elasticsearch, install a service wrapper, move files and directories here and there, etc. Overkill.

Installing it is pretty simple using the provided RPM from the Elasticsearch website.

cd ~
sudo yum update
sudo yum install java-1.7.0-openjdk -y

wget https://download.elasticsearch.org/elasticsearch/elasticsearch/elasticsearch-0.90.10.noarch.rpm

rpm -Uvh elasticsearch-0.90.10.noarch.rpm 

chkconfig elasticsearch on

If you are installing for SugarCRM (which is a majority of the traffic generated to this post), I recommend adding the following to the configuration file located at /etc/elasticsearch/elasticsearch.yml

Testing

Testing to make sure it works is pretty straight forward. Using curl we will make sure the service is running on the standard port of 9200.

curl http://localhost:9200

The results returned should resemble something along the following lines.

{
  "ok" : true,
  "status" : 200,
  "name" : "Vagabond",
  "version" : {
    "number" : "0.90.8",
    "build_hash" : "909b037218cf880e8772b066a764f179f2d5e719",
    "build_timestamp" : "2013-12-18T16:08:16Z",
    "build_snapshot" : false,
    "lucene_version" : "4.6"
  },
  "tagline" : "You Know, for Search"
}

Full Text Search Examples

See the following links for more information on how to use Elasticsearch as a whole and some more specific SugarCRM examples.

http://joelabrahamsson.com/elasticsearch-101/

http://developer.sugarcrm.com/2012/07/06/full-text-search-tricks/

Convert All MyISAM Tables To InnoDB

Today I took on the task of converting our SugarCRM MySQL MyISAM tables to InnoDB. Currently we have roughly 200 tables in the SugarCRM DB. Its a time consuming processes to convert each table one at a time. Luckily, using some SQL scripting you can make this much less painful.

Start by running the following query to build a list of SQL statements that will handle converting each table.

The output generates a query for each table to be converted to InnoDB.

Copy and paste these results and run the queries. After some time (in my case about 20 minutes) all of the tables in the DB will be converted to InnoDB.