elastic search

22
Elastic Search Pavan Navule

Upload: navule-rao

Post on 05-Apr-2017

128 views

Category:

Technology


0 download

TRANSCRIPT

Page 1: Elastic Search

Elastic SearchPavan Navule

Page 2: Elastic Search

Contents

▪ Introduction▪ Terminology

– Index, Type, Document, Field– Comparison with Relational Database

▪ Architecture– Clusters, Nodes, Shards & Replicas

▪ Search– How it works?– Inverted Index

▪ Installation & Configuration– Setup & Run Elastic Server

▪ Elastic in Action– Indexing, Querying & Deleting

Page 3: Elastic Search

Introduction

Distributed

Page 4: Elastic Search

Terminology

▪ Index– Is means of storing different types of data.– Can span across one primary shard or multiple shards.– Identified by metadata field _index– An Index can contain multiple types

Page 5: Elastic Search

Terminology

▪ Type– A type is a convenient way to store a specific type of

data within an index– Identified by metadata field _type

Page 6: Elastic Search

Terminology

▪ Document–A document is JSON object (set

of ‘key-value’ pairs aka fields)▪ _type▪ _id▪ _source

Page 7: Elastic Search

Terminology

▪ Field– Key▪ type (data type)▪ Format

– Value▪ Can hold scalar data (int, string

values) or Nested structures like array or object

Page 8: Elastic Search

Terminology (Comparison with RDBMS)

Index

TypeId

Status

1 Reserved

2 In House3 Departe

dDocument

1 Reserved

Page 9: Elastic Search

Architecture

https://prezi.com/hmxfrorhtcq-/elasticsearch/

Page 10: Elastic Search

Search

How Elastic Search Works?

N

N

N

N

N

Cluster• Master Node• Multicast to find other nodes• Manage Cluster State• Assign Shards to Nodes

Page 11: Elastic Search

N

N

N

N

Search

How Elastic Search Works?

N

N

N

NCluster Replica

Page 12: Elastic Search

Search

Internode Communication

• Sends parallel Queries to all nodes

• Merges the full response

• Response returned to the user

N

N

N

NCluster

P2P Architecture

Default Port 9300

Page 13: Elastic Search

Search

Inverted Index

Text Processing

• Tokenize• Remove

duplicates• Sort

Math

• Frequency

Discover

• Identify & List the documents

Page 14: Elastic Search

Search

Doc #

Contents

1 Fantastic Beasts and Where to Find Them

2 Beasts of the Southern Wild 3 The Wild Life4 Life of a Pi

Term Frequency

Documents

and 2 1beasts 2 1,2fantastic 1 1find 1 1life 2 3,4of 2 2,4pi 1 4southern 1 2the 2 2,3them 1 1to 1 1where 1 1wild 2 2,3

Inverted Index

Page 15: Elastic Search

Installation

▪ Download from www.elastic.co/downloads/elasticsearch–Extract to your desired location▪ Configuration–Default port 9200–Configure ▪ Config file location

“~/elasticsearch-x.y.z/config/elasticsearch.yml“▪ node name▪ port▪ path for log files etc.,

Page 16: Elastic Search

Run Elastic Server

▪ Go to “~/elasticsearch-2.4.0/bin/“▪ Double click “elasticsearch.bat”

Page 17: Elastic Search

Indexing

SyntaxPOST /{index}/{type}/{optional-id}{ “key-1": "value", "key-2": "value", ... "key-n": "value",}

Example

POST /sampleindex/sampletype/{ "guestname": "Mr.J", "arrivaldate": "2016/12/12", "departuredate": "2016/12/14"}

Page 18: Elastic Search

Querying

Syntax ExampleSearch

GET /{index}/_search GET demo/_search

Search by type & id

GET /{index}/{type}/{id} GET demo/reservation/1

Search by property

GET /{index}/_search?q={propName}=“value"

GET /demo/_search?q=guestname="Mr.J"

Free search across index

GET /{index}/_search?q=‘value' GET demo/reservation/1

Page 19: Elastic Search

Deleting a Document

DELETE /{Index}/{Type}/{Id}Eg:DELETE demo/reservation/1

Page 20: Elastic Search

Review

▪ Introduction▪ Terminology

– Index, Type, Document, Field– Comparison with Relational Database

▪ Architecture– Clusters, Nodes, Shards & Replicas

▪ Search– How it works?– Inverted Index

▪ Installation & Configuration– Setup & Run Elastic Server

▪ Elastic in Action– Indexing, Querying & Deleting

Page 21: Elastic Search

Q&A

Page 22: Elastic Search

Thank You!