elasticsearch hello world

Elasticsearch needs java. Be sure to have a recent version of the jdk present on your system.
If not, install the latest version.

Get the latest elasticsearch archive from the official download page.

Non you can extract the archive content.

Go to the extracted folder and simply run elasticsearch this way: in the foreground directly from the binary inside the archive.

Easy ! isn’t it ? Keep this terminal command running and open a new terminal console.
Be sure you have the curl command installed on your system.
Now try to ping elasticsearch…

Perfect. We got a response. Now you undesrtand how we will communicate with elasticearch.
Lets index a document. It as blog post with a title, a comment and tags associated.

Now we have a document stored with id 1 in blog index and post type. Notice we’re using an empty pretty parameter each time: this way the json response from elasticsearch is nicely formated.

Now store 2 new blog posts.

Now use the search endpoint with an empty request. Elasticsearch will return every document stored.

If we want to search for a word, we can use the simplest way for that in the query string: ‘q=title:post’.
We’re looking for all blog post containing the word ‘post’ in the title.

Congrats ! With this simple tutorial you launched elasticsearch, stored documents and searched for them ! Off course elasticsearch provide a lot more features.
Installation of a production setup is more tricky. The different type of queries are impressive and elasticsearch can handle analytics, geo points, scalability, suggesters and more !