quick intro to elastic search

29
ElasticSearch Introduction and quick startup medcl 9-29

Upload: medcl

Post on 26-Jan-2015

115 views

Category:

Technology


5 download

DESCRIPTION

quick intro to elastic search

TRANSCRIPT

Page 1: quick intro to elastic search

ElasticSearch

Introduction and quick startupmedcl 9-29

Page 2: quick intro to elastic search

introduction

• ElasticSearch,a distributed search solution ,– domain driven– schema free– anything pluggable– open source, distributed, RESTful

• Author:shay.banon (expert in search and analytics)– Compass– GigaSpaces

• Current Version 0.11.0

Page 3: quick intro to elastic search

Features

• Reliable, Asynchronous Write Behind for long term persistency.

• (Near) Real Time Search.• Built on top of Lucene.– shard is a fully functional Lucene index.– All the power of Lucene easily exposed through simple

configuration / plugins.• Per operation consistency– Single document level operations are atomic, consistent,

isolated and durable.• Open Source under Apache 2 License.

Page 4: quick intro to elastic search

Distributed and Highly Available

• Each index is fully sharded with a configurable number of shards.

• Each shard can have zero or more replicas.• Read / Search operations performed on either

replica shard.

Page 5: quick intro to elastic search

Multi Tenant with Multi Types.

• Support for more than one index.• Support for more than one type per index.• Index level configuration (number of shards,

index storage, ...).

Page 6: quick intro to elastic search

Document oriented

• No need for upfront schema definition.• Schema can be defined per type for

customization of the indexing process.

Page 7: quick intro to elastic search

Various set of APIs.

• HTTP RESTful API.• Native Java API.• 3rd Clients– perl、 python、 php、 ruby、 groovy、 erlan

g、 .NET• All APIs perform automatic node operation

rerouting.

Page 8: quick intro to elastic search

UP AND RUN

Page 9: quick intro to elastic search

install

• Zero Conf

Page 10: quick intro to elastic search

index• $ curl -XPUT http://localhost:9200/twitter/user/kimchy -d '{ "name" : "Shay

Banon" }'

$ curl -XPUT http://localhost:9200/twitter/tweet/1 -d '{ "user": "kimchy", "post_date": "2009-11-15T13:12:00", "message": "Trying out Elastic Search, so far so good?" }'

$ curl -XPUT http://localhost:9200/twitter/tweet/2 -d '{ "user": "kimchy", "post_date": "2009-11-15T14:12:12", "message": "You know, for Search" }'

Page 11: quick intro to elastic search

Schema mapping

• $ curl -XPUT http://localhost:9200/twitter

$ curl -XPUT http://localhost:9200/twitter/user/_mapping -d '{ "properties" : { "name" : { "type" : "string" } }}'

Page 12: quick intro to elastic search

GET

• $ curl -XPUT http://localhost:9200/twitter/tweet/2 -d '{ "user": "kimchy", "postDate": "2009-11-15T14:12:12", "message": "You know, for Search" }'

$ curl -XGET http://localhost:9200/twitter/tweet/2

Page 13: quick intro to elastic search

Search• $ curl -XPUT http://localhost:9200/twitter/tweet/2 -d '

{ "user": "kimchy", "postDate": "2009-11-15T14:12:12", "message": "You know, for Search" }'

$ curl -XGET http://localhost:9200/twitter/tweet/_search?q=user:kimchy

$ curl -XGET http://localhost:9200/twitter/tweet/_search -d '{ "query" : { "term" : { "user": "kimchy" } } }'

$ curl -XGET http://localhost:9200/twitter/_search?pretty=true -d '{ "query" : { "range" : { "post_date" : { "from" : "2009-11-15T13:00:00", "to" : "2009-11-15T14:30:00" } } } }'

Page 14: quick intro to elastic search

multenancy• $ curl -XPUT http://localhost:9200/kimchy

$ curl -XPUT http://localhost:9200/elasticsearch

$ curl -XPUT http://localhost:9200/elasticsearch/tweet/1 -d \'{ "post_date": "2009-11-15T14:12:12", "message": "Zug Zug", "tag": "warcraft" }'

$ curl -XPUT http://localhost:9200/kimchy/tweet/1 -d \'{ "post_date": "2009-11-15T14:12:12", "message": "Whatyouwant?", "tag": "warcraft" }'

$ curl -XGET http://localhost:9200/kimchy,elasticsearch/tweet/_search?q=tag:warcraft

$ curl -XGET http://localhost:9200/_all/tweet/_search?q=tag:warcraft

Page 15: quick intro to elastic search

Setting• $ curl -XPUT http://localhost:9200/kimchy/ -d \

'index : store: type: memory'

$ curl -XPUT http://localhost:9200/elasticsearch/ -d \' { "index" : { "number_of_shards" : 2, "number_of_replicas" : 3 }}'

Page 16: quick intro to elastic search

BEHIND ELASTICSEARCH

Page 17: quick intro to elastic search

Modules

Page 18: quick intro to elastic search

scalability

• nodes that can hold data, and nodes that do not.

• There is no need for a load balancer in elasticsearch, each node can receive a request, and if it can’t handle it, it will automatically delegate it to the appropriate node(s).

• If you want to scale out search, you can simply have more shard replicas per shard.

Page 19: quick intro to elastic search

automatic shard allocation

From:http://www.slideshare.net/elasticsearch/elasticsearch-at-berlinbuzzwords-2010#

Page 20: quick intro to elastic search

BASE support

• Each document you index is there once the index operation is done.

• No need to commit or something similar to get everything persisted.

• A shard can have 1 or more replicas for HA. • Gateway persistency is done in the

background in an async manner.

Page 21: quick intro to elastic search

The River

• A river is a pluggable service running within elasticsearch cluster pulling data (or being pushed with data) that is then indexed into the cluster.

Page 22: quick intro to elastic search

Geo Location and Search

• 1. make your data geo enabled• {

"pin" : { "location" : { "lat" : 40.12, "lon" : -71.34 }, "tag" : ["food", "family"], "text" : "my favorite family restaurant" }}

• Find By Location• Sorting• Faceting … …

Page 23: quick intro to elastic search

• More details in http://www.elasticsearch.com/docs/

Page 24: quick intro to elastic search

COMPARISON

Page 25: quick intro to elastic search

Compare with solr

• Though support dynamic schema,but it sucks– *i ,name_i,age_i,….

• Distribute ,just do many replica,Master-Slave,and with a dirty query like this:– http://localhost:9080/solr/select/?q=xxx:xxx&shar

ds=localhost:8080/solr,localhost:9080/solr WTF!

• Does it really RESTful?anyway, doesn’t matter

Page 26: quick intro to elastic search

Compare with katta• Featrures

– Makes serving large or high load indices easy– Serves very large Lucene or Hadoop Mapfile indices as index shards on many servers– Replicate shards on different servers for performance and fault-tolerance– Supports pluggable network topologies– Master fail-over– Fast, lightweight, easy to integrate– Plays well with Hadoop clusters

• May heavy to us(may be not)• Master-Node,complex and ops will killed us? can’t be a little easy?• Lack of Client and documents• Inactivity Community• Lake of Some Search Features

Page 27: quick intro to elastic search

RESOURCES

Page 28: quick intro to elastic search

• Link:– http://www.elasticsearch.com– http://www.elasticsearch.com/blog– http://www.elasticsearch.com/docs/– http://www.elasticsearch.com/community/mailinglist/user/– http://github.com/elasticsearch

• References:– http://highscalability.com/blog/2010/2/10/elasticsearch-open-s

ource-distributed-restful-search-engine.html– http://blog.sematext.com/2010/05/03/elastic-search-distribute

d-lucene/– http://mail-archives.apache.org/mod_mbox/hbase-user/201006

.mbox/%[email protected]%3E

– http://www.slideshare.net/elasticsearch/elasticsearch-at-berlinbuzzwords-2010#

Page 29: quick intro to elastic search

• Thanks/