Skip to content

Setting Up Local Elasticsearch Server

RichBCurious edited this page Jul 31, 2015 · 2 revisions

Note: These instructions assume you are working on a Mac.

If you haven't done it already, install elastic search. Follow the instructions on the ElasticSearch website Be sure to also install marvel. That is a great tool for querying your ES server.

Once installed, modify the yml file to give your cluster a unique name. The file should be located at /usr/local/opt/elasticsearch/config/elasticsearch.yml. Look for the line,

cluster.name: elasticsearch  

Change it to something unique. For example,

cluster.name: elasticsearch_murakami

You can leave everything else as the defaults. However, if you do want to customize your ElasticSearch instance, this is the file you would do it in.

Start your instance by running the following commands from a terminal window:

cd /usr/local/opt/elasticsearch
./bin/elasticsearch 

Verify that your elasticsearch cluster is running by using sense. Open a browser and type in the following:

http://localhost:9200/_plugin/marvel/sense/

Then in the "Server" text box, make sure you see the following:

localhost:9200

In the window below the "Server" text box type the following:

GET _cluster/health

Then put the cursor on that line. The entire line should be highlighted and a green right arrow button should appear. Click on that to run the command.

The results of the command (which is a standard elasticsearch command) will be shown in the window on the right. If the status that shows up in the right window says, "green", all is well. If it says, "red" or "yellow" that means there is a problem.

Note that you can run any elasticsearch command here. This is where you can run queries against your data. For more information on the commands you can run, see the elasticsearch documentation.

Once you've verified that your cluster is healthy, the next thing to do is update the config.groovy file to point to your running instance. In the development environment comment out the following line:

elasticSearch.client.mode = 'local'

Then add the following lines (or uncomment them, if they are already there):

elasticSearch.client.mode = ‘transport’
elasticSearch.cluster.name = ‘elasticsearch_murakami’
elasticSearch.client.hosts = [
    [host:'127.0.0.1', port:9300],
]

Obviously, you would use the cluster name you set in the elasticsearch.yml file. So in the above case, cluster.name setting is assumed to be 'elasticsearch_murakami'.

Finally, run the application and begin adding/removing/editing users, discussions, etc. You can use marvel sense (as shown above) to run any elasticsearch command. Note that as of this writing, data stored prior to making above changes will not be included in the elasticsearch instance. Only data that you added (or modified, I believe, but am not positive about) since making the changes will be included.

Note that as long as you have things configured this way, you will need to manually start your elasticsearch cluster before running the grails application.

Clone this wiki locally