12
Karel Mina ř ík @karmiq elasticsearch

Elasticsearch (Rubyshift 2013)

Embed Size (px)

DESCRIPTION

General introduction to Elasticsearch at the RubyShift 2013 conference. Download the source code for demos: * http://git.io/hello-elasticsearch-ruby * http://git.io/stackexchange-elasticsearch

Citation preview

Page 1: Elasticsearch (Rubyshift 2013)

Karel Minařík@karmiq

elasticsearch

Page 2: Elasticsearch (Rubyshift 2013)

What is Elasticsearch?

Page 3: Elasticsearch (Rubyshift 2013)

ElasticsearchFlexible REST API & JSON documents; API

driven configuration; scripting; index aliases; …

Scalable Distributed; built for cloud; …

Versatile Search; analytics; storage; alerting; text clustering; NLP …

Open Open source; community; plugins; …

Page 4: Elasticsearch (Rubyshift 2013)

Demo

http://git.io/hello-elasticsearch-ruby

Page 5: Elasticsearch (Rubyshift 2013)

http://stackoverflow.com

total

title

date author

rating

answers

result ordering

querysyntax

excerpt

highlight

Page 7: Elasticsearch (Rubyshift 2013)

Schema-less is not schema-free

Page 8: Elasticsearch (Rubyshift 2013)

Flat structureAn index per model. "Common search" scenario. Cannot cross-search.

users

questions

answers

comments

{ "name" : "John", "location" : "..."}

{ "title" : "My First Question", "body" : "..."}

{ "title" : "My First Answer", "body" : "..."}

{ "body" : "Just a comment: ..."}

Page 9: Elasticsearch (Rubyshift 2013)

DenormalizedCheap to query, expensive to update.

{ "title": "My first question", "body": "...",

"user": { "name": "John", "location": "..." },

"comments": [ { "text": "Good question!", "user": { "name": "Robert", "location": "..." } } ]}

questions

answers

Page 10: Elasticsearch (Rubyshift 2013)

Compromised denormalisation

Some properties don't change (user_name). Some can either be "freezed" or we have to pay the price of the mass update (user_location).

{ "id" : "john", "name" : "John", "location" : "..."}

myapp

user

question

answer

{ "id" : 1, "title" : "My first question", "body" : "...", "user" : { "name" : "John", "location" : "..." }, "comments" : [ { "body" : "...", "user" : { ... } }, { "body" : "...", "user" : { ... } } ]}

{ "id" : 2, "title" : "My first answer", "parent_id" : 1, "user" : { "name" : "Robert", "location" : "..." }, "comments" : [ { "body" : "...", "user" : { ... } } ]}

parent_id

comment

comment

Page 12: Elasticsearch (Rubyshift 2013)

thanks!