26
ElasticSearch A search engine “ready to fly” Medcl/2012/2/18

Elastic search intro-@lamper

  • Upload
    medcl

  • View
    1.339

  • Download
    5

Embed Size (px)

DESCRIPTION

lamper 2012/02/18 anyshare

Citation preview

Page 1: Elastic search intro-@lamper

ElasticSearchA search engine “ready to fly”

Medcl/2012/2/18

Page 3: Elastic search intro-@lamper

Why I am here?

• 好东西需要与大家一起分享!

Page 4: Elastic search intro-@lamper

What’s elasticsearch

• “Distributed, (Near) Real Time, Search Engine”

• Open Source(Apache 2.0)• RESTful• Free Schema(Dynamic)• MultiTenant• Scalable• High Availability• Rich Search Features• Good Extensibility• … …

Page 5: Elastic search intro-@lamper

first impression

Page 6: Elastic search intro-@lamper
Page 7: Elastic search intro-@lamper
Page 8: Elastic search intro-@lamper

Let’s start

the trip

Page 9: Elastic search intro-@lamper

Debug Tools

Page 10: Elastic search intro-@lamper

Index a document

curl –XPOST http://localhost:9200/myindex/share/1

-d’

{

"url" : "http://www.lamper.cn/",

"date" : "2012-02-18 13:00:00",

"location" : "beijing,北京"

}’

RESTfulURL地址

索引文档内容,Json格式

Field字段名称

字段内容

Page 11: Elastic search intro-@lamper

Index Response

{

"ok": true,

"_index": "myindex",

"_type": "share",

"_id": "1",

"_version": 1

}

Page 12: Elastic search intro-@lamper

Explain the url

http://localhost:9200/myindex/share/1

服务器IP地址

HTTP端口

索引名称

索引类型名称

索引文档唯一标识

Page 13: Elastic search intro-@lamper

Query the document

curl –XGET http://localhost:9200/myindex/share/_search?q=location:beijing

ES服务器地址

索引名称

类型名称

搜索RESTful接口

指定查询条件

查询条件,

字段名:值

Page 14: Elastic search intro-@lamper

Search Response

{ "took": 12, "timed_out": false,

"_shards": { "total": 5, "successful": 5, "failed": 0 },

"hits": {

"total": 1, "max_score": 0.5,

"hits": [ {

"_index": "myindex",

"_type": "share",

"_id": "1",

"_score": 0.5,

"_source": {

"url": "http://www.lamper.cn/",

"date": "2012-02-18 13:00:00",

"location": "beijing,北京"

} } ] }}

Page 15: Elastic search intro-@lamper

Queries

http://localhost:9200/myindex/share/_search?q=beijing

http://localhost:9200/myindex/share,conf/_search?q=beijing

http://localhost:9200/myindex/_search?q=beijing

http://localhost:9200/myindex,myindex2/_search?q=beijing

http://localhost:9200/_search?q=beijing

Page 16: Elastic search intro-@lamper

QueryDSL

curl -XPOST http://localhost:9200/myindex/_search –d’

{

"query": {

"term": {

"location": "beijing"

}

}

}’

Why QueryDSL?

Filters、Caching、Highlighting、Facet、

ComplexQuery… …

Page 17: Elastic search intro-@lamper

Scalability&HA

Page 18: Elastic search intro-@lamper

Distributed Lucene Directory

• 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 20: Elastic search intro-@lamper

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 21: Elastic search intro-@lamper

Transaction log

• Indexed / deleted doc is fully persistent

• No need for a Lucene IndexWriter#commit

• Managed using a transaction log / WAL

• Full single node durability (kill dash 9)

• Utilized when doing hot relocation of shards

• Periodically “flushed” (calling IW#commit)

Page 22: Elastic search intro-@lamper

BASE

• 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 23: Elastic search intro-@lamper

Not Mentioned Here…

• Versioning• Template• River• Percolator• PartialUpdate• Routing• Parent-Child Type• Scripting• … …

That’s Too Much,Discovery it yourself

Page 24: Elastic search intro-@lamper

Community&Support

• http://github.com/elasticsearch

• http://groups.google.com/group/elasticsearch

• Irc:#elasticsearch@freenode

• qq群:190605846

• http://doc.elasticsearch.cn

• http://s.medcl.net/

Page 25: Elastic search intro-@lamper

BTW

• 招人in’– 分布式

– 高性能

– 海量数据处理

– 个性化推荐

– 搜索引擎

• 对以上任一感兴趣者:

– 欢迎加入我们的团伙!

My Company!

Page 26: Elastic search intro-@lamper

Thank you!