Elasticsearch with Docker in five minutes

What is Elasticsearch?

Elasticsearch is a search server based on Lucene. It provides a distributed, multitenant-capable full-text search engine with a RESTful web interface and schema-free JSON documents.
Elasticsearch is a registered trademark of Elasticsearch BV.

What is Docker?

Docker is the world’s leading software container platform. Developers use Docker to eliminate “works on my machine” problems when collaborating on code with co-workers. Operators use Docker to run and manage apps side-by-side in isolated containers to get better compute density. Enterprises use Docker to build agile software delivery pipelines to ship new features faster, more securely

Installing Elasticsearch

docker pull docker.elastic.co/elasticsearch/elasticsearch:5.6.0

You should see something like this in the terminal.

Running Elasticsearch

docker run -p 9200:9200 -e "http.host=" -e "transport.host=" docker.elastic.co/elasticsearch/elasticsearch:5.6.0

You can access it at http://localhost:9200 on your web browser.
Note: X-Pack is preinstalled in this image. Please take a few minutes to familiarize yourself with X-Pack Security and how to change default passwords. The default password for the elastic user is changeme.

"tagline":"You Know, for Search"

Indexing new items

curl --user elastic:changeme -XPUT 'http://localhost:9200/recipes/recipe/3' -d '
"title": "Roasted Pepper and Bacon Omelet",
"href": "http://www.bigoven.com/43919-Roasted-Pepper-and-Bacon-Omelet-recipe.html",
"ingredients": "eggs, salt, black pepper, butter, black pepper, bacon, onions, garlic, roasted red peppers, oregano, black pepper",
"thumbnail": ""

Searching for items

Search all the recipes with contains Broccoli in the title

curl --user elastic:changeme 'http://localhost:9200/recipes/recipe/_search?q=title:Broccoli&pretty=true
"title":"Broccoli and Cheese Omelet",
"ingredients":"onions, garlic, chicken broth, cottage cheese, oregano, black pepper, egg substitute, bread, mozzarella cheese, butter",


To shutdown Elasticsearch, hit Ctrl+C. This will shutdown ElasticSearch cleanly.