Slide 1

Slide 1 text

ElasticSeach 101 Lucas Saldanha® - http://www.lucassaldanha.com 1

Slide 2

Slide 2 text

Agenda • What is ElasticSearch • Basic Concepts • Indexing and Searching • Rest API • Inverted index • Analysis • Querying Lucas Saldanha® - http://www.lucassaldanha.com 2

Slide 3

Slide 3 text

What is ElasticSearch? • Document oriented database • JSON format • Built on top of Lucene • Focus on information retrieval features • Good use cases: • Textual search • Data aggregation • Geo Search • JSON document storage Lucas Saldanha® - http://www.lucassaldanha.com 3

Slide 4

Slide 4 text

Basic Concepts • Cluster: a set of nodes (servers) that holds all the data • Node: a single server that holds some data and participate on the cluster’s indexing and querying • Index: a set of documents • Shard: a subset of documents of an index. A index can be divided in many shards • Type: a definition of the schema of documents inside of an index (can be more than one) • Document: a JSON object with some data. It’s the basic unit of information in ES Lucas Saldanha® - http://www.lucassaldanha.com 4

Slide 5

Slide 5 text

Nodes Cluster Index Shard Lucas Saldanha® - http://www.lucassaldanha.com 5

Slide 6

Slide 6 text

Rest API Inserting document Querying Lucas Saldanha® - http://www.lucassaldanha.com 6

Slide 7

Slide 7 text

Query API in Action (image taken from the slides of the presentation An ElasticSearch Crash Course, by Andrew Cholakian) Lucas Saldanha® - http://www.lucassaldanha.com 7

Slide 8

Slide 8 text

Inverted Index (image taken from the slides of the presentation An ElasticSearch Crash Course, by Andrew Cholakian) Lucas Saldanha® - http://www.lucassaldanha.com 8

Slide 9

Slide 9 text

Analysis • Breaks chunks of texts in terms (tokens) • Helps building the inverted index • ElasticSearch comes with a lot of analyzers (but you can also write yours) • Examples: • Snowball analyzer: remove stop words and transform terms to the stemmed form • “The world tallest building” -> [“world”, “tall”, “building”] • N-gram analyzer: break terms in n-grams (good for autocomplete) • “future” -> [“fut”, “ure”] Lucas Saldanha® - http://www.lucassaldanha.com 9

Slide 10

Slide 10 text

Querying • ElasticSearch comes a lot of queries types (near 40 the last time I counted) • You can use the best one for your need • Queries can be combined • Examples: • Term/Phrase query: search documents with a specific list of terms • Geo Query: search documents inside a boundary • Numeric range query: search documents inside some interval Lucas Saldanha® - http://www.lucassaldanha.com 10

Slide 11

Slide 11 text

References • http://www.lucassaldanha.com/elasticsearch-101/ • https://www.elastic.co/guide/en/elasticsearch/reference/current/ind ex.html • https://www.elastic.co/videos/an-elasticsearch-crash-course • https://www.loggly.com/blog/loggly-chose-elasticsearch-reliable- scalable-log-management/ • http://www.slideshare.net/kucrafal/scaling-massive-elastic-search- clusters-rafa-ku-sematext • https://www.elastic.co/guide/en/elasticsearch/guide/current/relevan ce-intro.html Lucas Saldanha® - http://www.lucassaldanha.com 11