Show Menu
Cheatography

ElasticSearch For SQL People Cheat Sheet (DRAFT) by

Help SQL People Understand ElasticSearch

This is a draft cheat sheet. It is a work in progress and is not finished yet.

Equivalent Terms

SQL
Elasti­cSearch
Database
Index
Table
Type
Row
Document
Column
Field

Defini­tions (?)

Index
Collection of one or more shards
Shard
Apache Lucene Instance
Cluster
One or more nodes
Nodes
Server instances
Routing
A way to control what shard a document goes to (used for perfor­mance)
Segment
Internal lucene data block

Resilience & Scalab­ility

Shard(s)
One Primary, N Replicas
Index
Made of one or more shards
Cluster
Made of one or more nodes
Nodes
A single server in a cluster
Shard
Logical partition of an index across the nodes in a cluster
Replica
Number of copies of the primary shards in a cluster
Total shards in cluster
= primary shards * (replica count + 1)
Shards per node
= Total shards in cluster / # of nodes
 

Things Handled By

Elasti­cSearch
Apache Lucene
Node management
Searching
Shard management
Indexing
Health monitoring
Stemming
Parall­elizing Work
Serialized Workload

Parent­-Child vs Nested

Sharding
Children reside in Parent's shard
Parent­-Child
Cheap to update, slow to query
Nested
Cheap to query, slow to update
 

Crud Commands

PUT server­/in­dex­/ty­pe/ID JSON
Creates doc from JSON using ID
POST server­/in­dex­/type JSON
Creates doc from JSON and generates ID
POST server­/in­dex­/ty­pe/­ID/­_update JSON
Updates part of the document matching on ID
GET server­/in­dex­/ty­pe/ID
Retrieves doc matching ID
DELETE server­/in­dex­/ty­pe/ID
Deletes doc matching ID

Search Commands

GET server­/in­dex­/ty­pe/­_se­arc­h?q=XXX
Simple
Search index\type with query XXX
POST server­/in­dex­/ty­pe/­_search JSON
Complex
Search index\type with query in JSON

Big Ideas

Forward Index
Maps a document to a set of words
Inverted Index
Maps a word to a set of documents
Stemming
Converting a word to it's root, ie raining -> rain
Synonyms
Converts a word to an approp­riate equiva­lent, ie Sunday -> weekend
Lucene uses an Inverted Index to find documents so quickly.
Lucene uses stems for it's indexes and search terms to increase hit ratio for searches.
Lucene uses synonyms to increase hit ratio for searches.