elk-stack

You Know, for Search

REference

Installing Elasticsearch

The standard Elasticsearch install comes with its own Java installation and an additional set of paid features which need a trial license.

You don’t want that for the cleanest installation. Find the latest release which:

And work out which versions of Java you can use to run Elasticsearch.

Running Elasticsearch in a Docker container

docker-compose -f labs/for-search/compose.yml up -d
docker logs elkstack_elasticsearch_1 

On Windows 10:

. ./labs/scripts/windows-tools.ps1
curl http://localhost:9200

What version are we running?

Indexing documents

Indexing is how you store data in Elasticsearch. There are client libraries for all the major languages, and you can use the REST API.

curl -H 'Content-Type: application/json' -XPOST 'http://localhost:9200/classes/_doc/elk-stack' --data-binary "@labs/for-search/data/elk-stack.json"
curl http://localhost:9200/classes/_doc/elk-stack

Add two more classes:

curl -H ‘Content-Type: application/json’ -XPOST ‘http://localhost:9200/classes/_doc/docker-fun’ –data-binary “@labs/for-search/data/docker-fun.json”

curl -H ‘Content-Type: application/json’ -XPOST ‘http://localhost:9200/classes/_doc/k8s-fun’ –data-binary “@labs/for-search/data/k8s-fun.json”

Check the details are stored:

curl http://localhost:9200/classes/_doc/docker-fun

curl http://localhost:9200/classes/_doc/k8s-fun

Basic searching

Querystring:

curl http://localhost:9200/classes/_search?q=fundamentals

curl http://localhost:9200/classes/_search?q=-fundamentals

curl -H ‘Content-Type: application/json’ http://localhost:9200/classes/_search?pretty=true –data-binary “@labs/for-search/queries/match-all.json”

curl -H ‘Content-Type: application/json’ http://localhost:9200/classes/_search?pretty=true –data-binary “@labs/for-search/queries/match-name.json”

curl -H ‘Content-Type: application/json’ http://localhost:9200/classes/_search?pretty=true –data-binary “@labs/for-search/queries/match-bool-name.json”

Lab

Stuck? Try hints or check the solution.