SlideShare a Scribd company logo
1 of 20
Elasticsearch V/s Relational Databases
Agenda
● Basic Difference Between Elasticsearch And Relational Database
● Use Cases where Relational Db are not suitable
● Basic Terminology Of Elasticsearch
● Elasticsearch – CRUD operations
Basic Difference
● Elasticsearch is a No sql Database.
● It has no relations, no constraints, no joins, no transactional
behaviour.
● Easier to scale as compared to a relational Database.
Relational DB Elasticsearch
DataBase Index
Table Type
Row/Record Document
Column Name Field
Usecases where Relational Databases
are not suitable
● Relevance based searching
● Searching when entered spelling of search term is wrong
● Full text search
● Synonym search
● Phonetic search
● Log analysis
Relevance Based searcching
● By default, results are returned sorted by relevance—with the most
relevant docs first.
● The relevance score of each document is represented by a positive
floating-point number called the _score. The higher the _score, the
more relevant the document.
● A query clause generates a _score for each document. How that
score is calculated depends on the type of query clause.
Relevance Representation in ES
{
"_index": "test",
"_type": "product",
"_id": "AV0iKK_ZJJfvpLB9dSHl",
"_score": 0.51623213, ====> Relevance Score calculated by ES
"_source": {
"id": 2,
"name": "Red Shirt"
}
}
Wrong Spelling searching
Query
● {
"query": {
"match": {
"name": {
"query": "shrt",
"fuzziness": 2,
"prefix_length": 0
}
}
}
}
Result
{
"_index": "test",
"_type": "product",
"_id": "AV0iKKplJJfvpLB9dSHk",
"_score": 0.21576157,
"_source": {
"id": 1,
"name": "Shirt"
}
}
Full Text Search
● Whenever a full-text is given to Elasticsearch, special analyzers are
applied in order to simplify it and make it searchable.
● It does not store the text as it is visible. This means that the original
text would be modified following special rules before being stored in
the Inverted index.
● This process is called the “analysis phase,” and it is applied to all full-
text fields.
Full Text- Analysis Phase
Full Text- Reverse Indexing
Synonym search
● Synonyms are used to broaden the scope of what is considered a
matching document.
● Perhaps no documents match a query for “Top Doctor's College,” but
documents that contain “Top Medical Institutions” would probably be
considered a good match.
Phonetic Searching
● Elasticsearch can search for words that sound similar, even if their
spelling differs.
● The Phonetic Analysis plugin provides token filters which convert
tokens to their phonetic representation using Soundex, Metaphone,
and a variety of other algorithms.
● Generally used while searching for names that sound similar.
Consider 'Smith', 'Smythe'. Elasticsearch analyser will produce same
tokens for both.
Log Analysis Using Elasticsearch
● Elasticsearch is vastly used as a centralized location for storing logs.
● For the purpose of indexing and searching logs, there is a bundled
solution offered at the Elasticsearch page - ELK stack, which stands
for elasticsearch, logstash and kibana.
●
Elasticsearch Terminology
● Elasticsearch: It is a horizontally distributed,data storage, search server,
aggregation engine, based on lucene library. It is written in java. Elasticsearch
5.5 is the latest one.
● Cluster: A cluster consists of one or more nodes which share the same cluster
name. Each cluster has a single master node which can be replaced if the
current master node fails.
● Node: A node is a running instance of elasticsearch which belongs to a cluster.
Multiple nodes can be started on a single server. At startup, a node will use
unicast to discover an existing cluster with the same cluster name and will try
to join that cluster.
● Primary Shard: Each document is stored in a single primary shard. When you
index a document, it is indexed first on the primary shard, then on all replicas
of the primary shard. By default, an index has 5 primary shards.
Elasticsearch Terminology Ctd.
● Replica Shard: Each primary shard can have zero or more replicas. A replica
is a copy of the primary shard. By Default there are 1 replica for each primary
shards.
● Document: A document is a JSON document which is stored in elasticsearch.
It is like a row in a table in a relational database. Each document is stored in
an index and has a type and an id. A document is a JSON object which
contains zero or more fields, or key-value pairs.
● ID: The ID of a document identifies a document. The index/type/id of a
document must be unique. If no ID is provided, then it will be auto-generated.
● Mapping: A mapping is like a schema definition in a relational database. Each
index has a mapping, which defines each type within the index, plus a number
of index-wide settings.
Create Index/Document
● Index Creation:
PUT employee
● Document Creation
POST employee/employee/1
{
"name" : "John"
}
Delete Document
● Delete By Id
DELETE employee/employee/1
● Delete By query
POST employee/employee/_delete_by_query
{
"query": {
"match": {
"name": "John"
}
}
}
Update Document
● Update By Id:
POST employee/employee/1/_update
{
"doc": {
"name": "Johny"
}
}
● Update By Query:
POST employee/_update_by_query
{
"script": {
"inline": "ctx._source.age++",
"lang": "painless"
},
"query": {
"match": {
"name": "john"
}
}
}
Read/Query Document
● Read By Id
GET employee/employee/1
● Read By query
GET employee/_search
{
"query": {
"match": {
"name": "John"
}
}
}
Thank You :)

More Related Content

What's hot

What's hot (20)

JavaScript Programming
JavaScript ProgrammingJavaScript Programming
JavaScript Programming
 
Introduction to MongoDB
Introduction to MongoDBIntroduction to MongoDB
Introduction to MongoDB
 
Mongodb basics and architecture
Mongodb basics and architectureMongodb basics and architecture
Mongodb basics and architecture
 
Elasticsearch
ElasticsearchElasticsearch
Elasticsearch
 
Json
JsonJson
Json
 
About elasticsearch
About elasticsearchAbout elasticsearch
About elasticsearch
 
Node js Introduction
Node js IntroductionNode js Introduction
Node js Introduction
 
JSON: The Basics
JSON: The BasicsJSON: The Basics
JSON: The Basics
 
MongoDB.pptx
MongoDB.pptxMongoDB.pptx
MongoDB.pptx
 
Rest API with Swagger and NodeJS
Rest API with Swagger and NodeJSRest API with Swagger and NodeJS
Rest API with Swagger and NodeJS
 
Introduction to MongoDB
Introduction to MongoDBIntroduction to MongoDB
Introduction to MongoDB
 
React-JS.pptx
React-JS.pptxReact-JS.pptx
React-JS.pptx
 
Redis overview for Software Architecture Forum
Redis overview for Software Architecture ForumRedis overview for Software Architecture Forum
Redis overview for Software Architecture Forum
 
Angularjs PPT
Angularjs PPTAngularjs PPT
Angularjs PPT
 
MongoDB 101
MongoDB 101MongoDB 101
MongoDB 101
 
Introduction to Swagger
Introduction to SwaggerIntroduction to Swagger
Introduction to Swagger
 
Javascript
JavascriptJavascript
Javascript
 
React JS
React JSReact JS
React JS
 
React JS - A quick introduction tutorial
React JS - A quick introduction tutorialReact JS - A quick introduction tutorial
React JS - A quick introduction tutorial
 
Indexing with MongoDB
Indexing with MongoDBIndexing with MongoDB
Indexing with MongoDB
 

Similar to Elasticsearch V/s Relational Database

Using elasticsearch with rails
Using elasticsearch with railsUsing elasticsearch with rails
Using elasticsearch with rails
Tom Z Zeng
 
Xml query language and navigation
Xml query language and navigationXml query language and navigation
Xml query language and navigation
Raghu nath
 

Similar to Elasticsearch V/s Relational Database (20)

Using elasticsearch with rails
Using elasticsearch with railsUsing elasticsearch with rails
Using elasticsearch with rails
 
Search engine. Elasticsearch
Search engine. ElasticsearchSearch engine. Elasticsearch
Search engine. Elasticsearch
 
Elasticsearch Architechture
Elasticsearch ArchitechtureElasticsearch Architechture
Elasticsearch Architechture
 
ElasticSearch Basic Introduction
ElasticSearch Basic IntroductionElasticSearch Basic Introduction
ElasticSearch Basic Introduction
 
Intro to elasticsearch
Intro to elasticsearchIntro to elasticsearch
Intro to elasticsearch
 
Search explained T3DD15
Search explained T3DD15Search explained T3DD15
Search explained T3DD15
 
Philly PHP: April '17 Elastic Search Introduction by Aditya Bhamidpati
Philly PHP: April '17 Elastic Search Introduction by Aditya BhamidpatiPhilly PHP: April '17 Elastic Search Introduction by Aditya Bhamidpati
Philly PHP: April '17 Elastic Search Introduction by Aditya Bhamidpati
 
Elasticsearch: Removal of types
Elasticsearch: Removal of typesElasticsearch: Removal of types
Elasticsearch: Removal of types
 
Elasticsearch selected topics
Elasticsearch selected topicsElasticsearch selected topics
Elasticsearch selected topics
 
Introduction to ElasticSearch
Introduction to ElasticSearchIntroduction to ElasticSearch
Introduction to ElasticSearch
 
Amazon Elasticsearch and Databases
Amazon Elasticsearch and DatabasesAmazon Elasticsearch and Databases
Amazon Elasticsearch and Databases
 
Elasticsearch
ElasticsearchElasticsearch
Elasticsearch
 
Lucene
LuceneLucene
Lucene
 
Elasticsearch: An Overview
Elasticsearch: An OverviewElasticsearch: An Overview
Elasticsearch: An Overview
 
Elastic search
Elastic searchElastic search
Elastic search
 
Wanna search? Piece of cake!
Wanna search? Piece of cake!Wanna search? Piece of cake!
Wanna search? Piece of cake!
 
Elasticsearch
ElasticsearchElasticsearch
Elasticsearch
 
Deep dive to ElasticSearch - معرفی ابزار جستجوی الاستیکی
Deep dive to ElasticSearch - معرفی ابزار جستجوی الاستیکیDeep dive to ElasticSearch - معرفی ابزار جستجوی الاستیکی
Deep dive to ElasticSearch - معرفی ابزار جستجوی الاستیکی
 
Index Structures.pptx
Index Structures.pptxIndex Structures.pptx
Index Structures.pptx
 
Xml query language and navigation
Xml query language and navigationXml query language and navigation
Xml query language and navigation
 

Recently uploaded

Recently uploaded (20)

Portal Kombat : extension du réseau de propagande russe
Portal Kombat : extension du réseau de propagande russePortal Kombat : extension du réseau de propagande russe
Portal Kombat : extension du réseau de propagande russe
 
Microsoft CSP Briefing Pre-Engagement - Questionnaire
Microsoft CSP Briefing Pre-Engagement - QuestionnaireMicrosoft CSP Briefing Pre-Engagement - Questionnaire
Microsoft CSP Briefing Pre-Engagement - Questionnaire
 
BT & Neo4j _ How Knowledge Graphs help BT deliver Digital Transformation.pptx
BT & Neo4j _ How Knowledge Graphs help BT deliver Digital Transformation.pptxBT & Neo4j _ How Knowledge Graphs help BT deliver Digital Transformation.pptx
BT & Neo4j _ How Knowledge Graphs help BT deliver Digital Transformation.pptx
 
Continuing Bonds Through AI: A Hermeneutic Reflection on Thanabots
Continuing Bonds Through AI: A Hermeneutic Reflection on ThanabotsContinuing Bonds Through AI: A Hermeneutic Reflection on Thanabots
Continuing Bonds Through AI: A Hermeneutic Reflection on Thanabots
 
TEST BANK For, Information Technology Project Management 9th Edition Kathy Sc...
TEST BANK For, Information Technology Project Management 9th Edition Kathy Sc...TEST BANK For, Information Technology Project Management 9th Edition Kathy Sc...
TEST BANK For, Information Technology Project Management 9th Edition Kathy Sc...
 
Choosing the Right FDO Deployment Model for Your Application _ Geoffrey at In...
Choosing the Right FDO Deployment Model for Your Application _ Geoffrey at In...Choosing the Right FDO Deployment Model for Your Application _ Geoffrey at In...
Choosing the Right FDO Deployment Model for Your Application _ Geoffrey at In...
 
Easier, Faster, and More Powerful – Notes Document Properties Reimagined
Easier, Faster, and More Powerful – Notes Document Properties ReimaginedEasier, Faster, and More Powerful – Notes Document Properties Reimagined
Easier, Faster, and More Powerful – Notes Document Properties Reimagined
 
Oauth 2.0 Introduction and Flows with MuleSoft
Oauth 2.0 Introduction and Flows with MuleSoftOauth 2.0 Introduction and Flows with MuleSoft
Oauth 2.0 Introduction and Flows with MuleSoft
 
Working together SRE & Platform Engineering
Working together SRE & Platform EngineeringWorking together SRE & Platform Engineering
Working together SRE & Platform Engineering
 
Integrating Telephony Systems with Salesforce: Insights and Considerations, B...
Integrating Telephony Systems with Salesforce: Insights and Considerations, B...Integrating Telephony Systems with Salesforce: Insights and Considerations, B...
Integrating Telephony Systems with Salesforce: Insights and Considerations, B...
 
Extensible Python: Robustness through Addition - PyCon 2024
Extensible Python: Robustness through Addition - PyCon 2024Extensible Python: Robustness through Addition - PyCon 2024
Extensible Python: Robustness through Addition - PyCon 2024
 
What's New in Teams Calling, Meetings and Devices April 2024
What's New in Teams Calling, Meetings and Devices April 2024What's New in Teams Calling, Meetings and Devices April 2024
What's New in Teams Calling, Meetings and Devices April 2024
 
Secure Zero Touch enabled Edge compute with Dell NativeEdge via FDO _ Brad at...
Secure Zero Touch enabled Edge compute with Dell NativeEdge via FDO _ Brad at...Secure Zero Touch enabled Edge compute with Dell NativeEdge via FDO _ Brad at...
Secure Zero Touch enabled Edge compute with Dell NativeEdge via FDO _ Brad at...
 
Long journey of Ruby Standard library at RubyKaigi 2024
Long journey of Ruby Standard library at RubyKaigi 2024Long journey of Ruby Standard library at RubyKaigi 2024
Long journey of Ruby Standard library at RubyKaigi 2024
 
AI mind or machine power point presentation
AI mind or machine power point presentationAI mind or machine power point presentation
AI mind or machine power point presentation
 
A Business-Centric Approach to Design System Strategy
A Business-Centric Approach to Design System StrategyA Business-Centric Approach to Design System Strategy
A Business-Centric Approach to Design System Strategy
 
Enterprise Knowledge Graphs - Data Summit 2024
Enterprise Knowledge Graphs - Data Summit 2024Enterprise Knowledge Graphs - Data Summit 2024
Enterprise Knowledge Graphs - Data Summit 2024
 
The Metaverse: Are We There Yet?
The  Metaverse:    Are   We  There  Yet?The  Metaverse:    Are   We  There  Yet?
The Metaverse: Are We There Yet?
 
Designing for Hardware Accessibility at Comcast
Designing for Hardware Accessibility at ComcastDesigning for Hardware Accessibility at Comcast
Designing for Hardware Accessibility at Comcast
 
Using IESVE for Room Loads Analysis - UK & Ireland
Using IESVE for Room Loads Analysis - UK & IrelandUsing IESVE for Room Loads Analysis - UK & Ireland
Using IESVE for Room Loads Analysis - UK & Ireland
 

Elasticsearch V/s Relational Database

  • 2. Agenda ● Basic Difference Between Elasticsearch And Relational Database ● Use Cases where Relational Db are not suitable ● Basic Terminology Of Elasticsearch ● Elasticsearch – CRUD operations
  • 3. Basic Difference ● Elasticsearch is a No sql Database. ● It has no relations, no constraints, no joins, no transactional behaviour. ● Easier to scale as compared to a relational Database. Relational DB Elasticsearch DataBase Index Table Type Row/Record Document Column Name Field
  • 4. Usecases where Relational Databases are not suitable ● Relevance based searching ● Searching when entered spelling of search term is wrong ● Full text search ● Synonym search ● Phonetic search ● Log analysis
  • 5. Relevance Based searcching ● By default, results are returned sorted by relevance—with the most relevant docs first. ● The relevance score of each document is represented by a positive floating-point number called the _score. The higher the _score, the more relevant the document. ● A query clause generates a _score for each document. How that score is calculated depends on the type of query clause.
  • 6. Relevance Representation in ES { "_index": "test", "_type": "product", "_id": "AV0iKK_ZJJfvpLB9dSHl", "_score": 0.51623213, ====> Relevance Score calculated by ES "_source": { "id": 2, "name": "Red Shirt" } }
  • 7. Wrong Spelling searching Query ● { "query": { "match": { "name": { "query": "shrt", "fuzziness": 2, "prefix_length": 0 } } } } Result { "_index": "test", "_type": "product", "_id": "AV0iKKplJJfvpLB9dSHk", "_score": 0.21576157, "_source": { "id": 1, "name": "Shirt" } }
  • 8. Full Text Search ● Whenever a full-text is given to Elasticsearch, special analyzers are applied in order to simplify it and make it searchable. ● It does not store the text as it is visible. This means that the original text would be modified following special rules before being stored in the Inverted index. ● This process is called the “analysis phase,” and it is applied to all full- text fields.
  • 10. Full Text- Reverse Indexing
  • 11. Synonym search ● Synonyms are used to broaden the scope of what is considered a matching document. ● Perhaps no documents match a query for “Top Doctor's College,” but documents that contain “Top Medical Institutions” would probably be considered a good match.
  • 12. Phonetic Searching ● Elasticsearch can search for words that sound similar, even if their spelling differs. ● The Phonetic Analysis plugin provides token filters which convert tokens to their phonetic representation using Soundex, Metaphone, and a variety of other algorithms. ● Generally used while searching for names that sound similar. Consider 'Smith', 'Smythe'. Elasticsearch analyser will produce same tokens for both.
  • 13. Log Analysis Using Elasticsearch ● Elasticsearch is vastly used as a centralized location for storing logs. ● For the purpose of indexing and searching logs, there is a bundled solution offered at the Elasticsearch page - ELK stack, which stands for elasticsearch, logstash and kibana. ●
  • 14. Elasticsearch Terminology ● Elasticsearch: It is a horizontally distributed,data storage, search server, aggregation engine, based on lucene library. It is written in java. Elasticsearch 5.5 is the latest one. ● Cluster: A cluster consists of one or more nodes which share the same cluster name. Each cluster has a single master node which can be replaced if the current master node fails. ● Node: A node is a running instance of elasticsearch which belongs to a cluster. Multiple nodes can be started on a single server. At startup, a node will use unicast to discover an existing cluster with the same cluster name and will try to join that cluster. ● Primary Shard: Each document is stored in a single primary shard. When you index a document, it is indexed first on the primary shard, then on all replicas of the primary shard. By default, an index has 5 primary shards.
  • 15. Elasticsearch Terminology Ctd. ● Replica Shard: Each primary shard can have zero or more replicas. A replica is a copy of the primary shard. By Default there are 1 replica for each primary shards. ● Document: A document is a JSON document which is stored in elasticsearch. It is like a row in a table in a relational database. Each document is stored in an index and has a type and an id. A document is a JSON object which contains zero or more fields, or key-value pairs. ● ID: The ID of a document identifies a document. The index/type/id of a document must be unique. If no ID is provided, then it will be auto-generated. ● Mapping: A mapping is like a schema definition in a relational database. Each index has a mapping, which defines each type within the index, plus a number of index-wide settings.
  • 16. Create Index/Document ● Index Creation: PUT employee ● Document Creation POST employee/employee/1 { "name" : "John" }
  • 17. Delete Document ● Delete By Id DELETE employee/employee/1 ● Delete By query POST employee/employee/_delete_by_query { "query": { "match": { "name": "John" } } }
  • 18. Update Document ● Update By Id: POST employee/employee/1/_update { "doc": { "name": "Johny" } } ● Update By Query: POST employee/_update_by_query { "script": { "inline": "ctx._source.age++", "lang": "painless" }, "query": { "match": { "name": "john" } } }
  • 19. Read/Query Document ● Read By Id GET employee/employee/1 ● Read By query GET employee/_search { "query": { "match": { "name": "John" } } }