Introduction to Elasticsearch

Shaunak Kashyap • @shaunak • Developer Advocate at Elastic

Why use Elasticsearch?

Full text search

Structured search

Faceted navigation

Analytics

Features

  • Easy to get starteddownload, extract, run!
  • Scalable — just add or remove nodes as needed
  • Well-documented HTTP API
  • Supported clients for .NET, Node.js, ..., even Perl ☻

Some Concepts

Document
The unit of data fed into Elasticsearch, in JSON format

{
  "from": "tony@stark.com",
  "to": [ "thor@avengers.org", "natasha@avengers.org" ],
  "subject": "Infinity Stones",
  "body": "..."
}
              
Index
A collection of documents stored in Elasticsearch
Type
The category of the document within an index

More Concepts

Shard
A part of an index, consisting of a subset of documents in that index
Node
A running Elasticsearch process
Cluster
A collection of nodes that can communicate with each other and share the same cluster.name

A cluster of one node


C:\elasticsearch-1.7.0> bin\elasticsearch
            

Creating an index


PUT /twitter
{
  "settings": {
    "number_of_shards": 3,
    "number_of_replicas": 1
  }
}
            

Add another node


C:\elasticsearch-1.7.0> bin\elasticsearch
            

Scaling horizontally


C:\elasticsearch-1.7.0> bin\elasticsearch
            

Lose a node


C:\elasticsearch-1.7.0> bin\elasticsearch
...
Ctrl-C
            

Indexing a document


PUT /twitter/tweet/311335361169195009
{
  "message": "In startup we are practice Outage Driven Infrastructure.",
  "@timestamp": "2013-03-12T04:38:29.000Z"
}
          

Searching for documents


GET twitter/_search?q=devops
          

 

Query Phase

 

Fetch Phase

Today we learned

  • Types of applications that can be built with Elasticsearch
  • Key features of Elasticsearch
  • Some sample index, search, and aggregations queries
  • Key concepts
  • How clusters work under the hood
  • How indexing and searching work under the hood

Thank You

Shaunak Kashyap • Developer Advocate at Elastic@shaunak

https://discuss.elastic.co/