SlideShare a Scribd company logo
1 of 7
Download to read offline
Elasticsearch 
Node 
It refers to a single running instance of Elasticsearch. 
 
Cluster [Database in RDBMS analogy] 
It is a collection of one or more nodes.  
 
Index [Table in RDBMS analogy] 
It is a collection of different types of documents and their properties. Index also uses 
the concept of shards to improve the performance. 
 
Document [Row in RDBMS analogy] 
It is a collection of fields in a specific manner defined in JSON format. Every document
                               
belongs to a type and resides inside an index. Every document is associated with a
                             
unique identifier called the UID. 
 
Shard 
Indexes are horizontally subdivided into shards. This means each shard contains all
                       
the properties of the document but contains less number of JSON objects than index.
                           
The horizontal separation makes shard an independent node, which can be store in
                         
any node. Primary shard is the original horizontal part of an index and then these
                             
primary shards are replicated into replica shards. 
 
Replicas 
Elasticsearch allows a user to create replicas of their indexes and shards. Replication
                         
not only helps in increasing the availability of data in case of failure, but also improves
                               
the performance of searching by carrying out a parallel search operation in these
                         
replicas. 
 
URLs 
Elasticsearch ​http://localhost:9200 
Kibana ​http://localhost:5601 
 
 
Syntax of REST API to query Elasticsearch using Query DSL (Domain Specific 
Language) 
 
<HTTP_VERB> <api>/<command> 
{ 
JSON Body 
} 
 
GET _cluster/health 
 
 
1. Create an Index 
PUT students 
{ 
"settings": { 
"index": { 
"number_of_shards": 1, 
"number_of_replicas": 0 
} 
} 
} 
 
2. Delete in Index 
DELETE students 
 
 
3. Add Documents one by one 
PUT /students/student/1 
{ 
"name": "Pratyush", 
"roll": 10, 
"city": "Gurgaon", 
"state": "Haryana", 
"desc": "Pratyush knows C, Java and PHP" 
} 
 
 
 
PUT /students/student/2 
{ 
"name": "Dushyant", 
"roll": 12, 
"city": "Rewari", 
"state": "Haryana", 
"desc": "Dushyant knows C and Java" 
} 
 
PUT /students/student/3 
{ 
"name": "Yogesh", 
"roll": 15, 
"city": "Bharatpur", 
"state": "Rajasthan", 
"desc": "Yogesh knows Java" 
} 
 
4. Bulk Add documents (Linux Command) 
curl -H "Content-Type: application/json" -XPOST 
"http://localhost:9200/students/_bulk" --data-binary "@students.json" 
 
5. View documents by Id 
GET /students/student/1 
 
6. Update a document 
PUT /students/student/1 
{ 
"name": "Pratyush Majumdar", 
"roll": 10, 
"city": "Gurgaon", 
"state": "Haryana" 
"desc": "Pratyush knows C, Java and PHP" 
} 
 
7. Get settings of any index 
GET /students/_settings 
 
 
 
 
 
 
Search API 
 
GET /students/_search 
{ 
"query":{ 
"match_all":{} 
} 
} 
 
GET students/student/_search 
{ 
"query":{ 
"query_string":{ 
"query":"Java" 
} 
} 
} 
 
GET /students/student/_search 
{ 
"query": { 
"query_string": { 
"default_field": "state", 
"query": "Haryana" 
} 
} 
} 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
Completion Suggester 
 
1. Mapping query 
 
PUT phones 
{ 
"mappings": { 
"phone" : { 
"properties" : { 
"suggest" : { 
"type" : "completion" 
}, 
"title" : { 
"type": "keyword" 
} 
} 
} 
} 
} 
 
 
2. Add Data with input 
PUT phones/phone/1 
{ 
"name" : "Apple iPhone 12 pro max", 
"suggest" : { 
"input": [  
"Apple",  
"iPhone",  
"Apple iPhone", 
"iPhone 12", 
"pro max", 
"Apple iPhone 12 pro max" 
], 
"weight" : 12 
} 
} 
 
 
 
 
 
 
PUT phones/phone/2 
{ 
"name" : "Apple iPhone 11 pro max", 
"suggest" : { 
"input": [  
"Apple",  
"iPhone",  
"Apple iPhone", 
"iPhone 11", 
"pro max", 
"Apple iPhone 11 pro max" 
], 
"weight" : 11 
} 
} 
 
PUT phones/phone/3 
{ 
"name" : "Apple iPhone X", 
"suggest" : { 
"input": [  
"Apple",  
"iPhone",  
"Apple iPhone", 
"iPhone X", 
"Apple iPhone X" 
], 
"weight" : 10 
} 
} 
 
PUT phones/phone/4 
{ 
"name" : "Apple iPhone 9 Plus", 
"suggest" : { 
"input": [  
"Apple",  
"iPhone",  
"Apple iPhone", 
"iPhone 9", 
"9 Plus", 
"Apple iPhone 9 Plus" 
], 
"weight" : 9 
} 
} 
 
 
 
 
3. Search using prefix Match 
GET phones/_search 
{ 
"suggest": { 
"song-suggest" : { 
"prefix" : "i",  
"completion" : {  
"field" : "suggest" 
} 
} 
} 
} 
 
4. Search using prefix Match with Fuzzy-ness of 2 (For miss-spelling) 
GET phones/_search 
{ 
"suggest": { 
"song-suggest" : { 
"prefix" : "Appel",  
"completion" : {  
"field" : "suggest", 
"fuzzy" : { 
"fuzziness" : 2 
} 
} 
} 
} 
} 
 
 

More Related Content

Similar to Elasticsearch

Elasticsearch & "PeopleSearch"
Elasticsearch & "PeopleSearch"Elasticsearch & "PeopleSearch"
Elasticsearch & "PeopleSearch"George Stathis
 
Workshop: Learning Elasticsearch
Workshop: Learning ElasticsearchWorkshop: Learning Elasticsearch
Workshop: Learning ElasticsearchAnurag Patel
 
ElasticSearch for .NET Developers
ElasticSearch for .NET DevelopersElasticSearch for .NET Developers
ElasticSearch for .NET DevelopersBen van Mol
 
ElasticSearch - index server used as a document database
ElasticSearch - index server used as a document databaseElasticSearch - index server used as a document database
ElasticSearch - index server used as a document databaseRobert Lujo
 
Using elasticsearch with rails
Using elasticsearch with railsUsing elasticsearch with rails
Using elasticsearch with railsTom Z Zeng
 
ElasticSearch Basic Introduction
ElasticSearch Basic IntroductionElasticSearch Basic Introduction
ElasticSearch Basic IntroductionMayur Rathod
 
Json to hive_schema_generator
Json to hive_schema_generatorJson to hive_schema_generator
Json to hive_schema_generatorPayal Jain
 
Getting started with Elasticsearch in .net
Getting started with Elasticsearch in .netGetting started with Elasticsearch in .net
Getting started with Elasticsearch in .netIsmaeel Enjreny
 
Getting Started With Elasticsearch In .NET
Getting Started With Elasticsearch In .NETGetting Started With Elasticsearch In .NET
Getting Started With Elasticsearch In .NETAhmed Abd Ellatif
 
Elasticsearch: An Overview
Elasticsearch: An OverviewElasticsearch: An Overview
Elasticsearch: An OverviewRuby Shrestha
 
Elasticsearch, a distributed search engine with real-time analytics
Elasticsearch, a distributed search engine with real-time analyticsElasticsearch, a distributed search engine with real-time analytics
Elasticsearch, a distributed search engine with real-time analyticsTiziano Fagni
 
FIWARE Global Summit - FIWARE Context Information Management
FIWARE Global Summit - FIWARE Context Information ManagementFIWARE Global Summit - FIWARE Context Information Management
FIWARE Global Summit - FIWARE Context Information ManagementFIWARE
 
Elastic search intro-@lamper
Elastic search intro-@lamperElastic search intro-@lamper
Elastic search intro-@lampermedcl
 
OrientDB introduction - NoSQL
OrientDB introduction - NoSQLOrientDB introduction - NoSQL
OrientDB introduction - NoSQLLuca Garulli
 
About elasticsearch
About elasticsearchAbout elasticsearch
About elasticsearchMinsoo Jun
 
Basics of JSON (JavaScript Object Notation) with examples
Basics of JSON (JavaScript Object Notation) with examplesBasics of JSON (JavaScript Object Notation) with examples
Basics of JSON (JavaScript Object Notation) with examplesSanjeev Kumar Jaiswal
 

Similar to Elasticsearch (20)

Elasticsearch
ElasticsearchElasticsearch
Elasticsearch
 
Elasticsearch & "PeopleSearch"
Elasticsearch & "PeopleSearch"Elasticsearch & "PeopleSearch"
Elasticsearch & "PeopleSearch"
 
Workshop: Learning Elasticsearch
Workshop: Learning ElasticsearchWorkshop: Learning Elasticsearch
Workshop: Learning Elasticsearch
 
No sql databases
No sql databasesNo sql databases
No sql databases
 
ElasticSearch for .NET Developers
ElasticSearch for .NET DevelopersElasticSearch for .NET Developers
ElasticSearch for .NET Developers
 
ElasticSearch - index server used as a document database
ElasticSearch - index server used as a document databaseElasticSearch - index server used as a document database
ElasticSearch - index server used as a document database
 
Using elasticsearch with rails
Using elasticsearch with railsUsing elasticsearch with rails
Using elasticsearch with rails
 
ElasticSearch Basic Introduction
ElasticSearch Basic IntroductionElasticSearch Basic Introduction
ElasticSearch Basic Introduction
 
Elasticsearch
ElasticsearchElasticsearch
Elasticsearch
 
Json to hive_schema_generator
Json to hive_schema_generatorJson to hive_schema_generator
Json to hive_schema_generator
 
Getting started with Elasticsearch in .net
Getting started with Elasticsearch in .netGetting started with Elasticsearch in .net
Getting started with Elasticsearch in .net
 
Getting Started With Elasticsearch In .NET
Getting Started With Elasticsearch In .NETGetting Started With Elasticsearch In .NET
Getting Started With Elasticsearch In .NET
 
The Glory of Rest
The Glory of RestThe Glory of Rest
The Glory of Rest
 
Elasticsearch: An Overview
Elasticsearch: An OverviewElasticsearch: An Overview
Elasticsearch: An Overview
 
Elasticsearch, a distributed search engine with real-time analytics
Elasticsearch, a distributed search engine with real-time analyticsElasticsearch, a distributed search engine with real-time analytics
Elasticsearch, a distributed search engine with real-time analytics
 
FIWARE Global Summit - FIWARE Context Information Management
FIWARE Global Summit - FIWARE Context Information ManagementFIWARE Global Summit - FIWARE Context Information Management
FIWARE Global Summit - FIWARE Context Information Management
 
Elastic search intro-@lamper
Elastic search intro-@lamperElastic search intro-@lamper
Elastic search intro-@lamper
 
OrientDB introduction - NoSQL
OrientDB introduction - NoSQLOrientDB introduction - NoSQL
OrientDB introduction - NoSQL
 
About elasticsearch
About elasticsearchAbout elasticsearch
About elasticsearch
 
Basics of JSON (JavaScript Object Notation) with examples
Basics of JSON (JavaScript Object Notation) with examplesBasics of JSON (JavaScript Object Notation) with examples
Basics of JSON (JavaScript Object Notation) with examples
 

More from Pratyush Majumdar

More from Pratyush Majumdar (7)

An Introduction to Pagespeed Optimisation
An Introduction to Pagespeed OptimisationAn Introduction to Pagespeed Optimisation
An Introduction to Pagespeed Optimisation
 
Aws Architecture Training
Aws Architecture TrainingAws Architecture Training
Aws Architecture Training
 
CrUx Report and Improving Web vitals
CrUx Report and Improving Web vitalsCrUx Report and Improving Web vitals
CrUx Report and Improving Web vitals
 
Selenium Automation
Selenium AutomationSelenium Automation
Selenium Automation
 
Making app cluster ready
Making app cluster readyMaking app cluster ready
Making app cluster ready
 
SEI CMMI presentation
SEI CMMI presentationSEI CMMI presentation
SEI CMMI presentation
 
Apache architecture
Apache architectureApache architecture
Apache architecture
 

Recently uploaded

DNT_Corporate presentation know about us
DNT_Corporate presentation know about usDNT_Corporate presentation know about us
DNT_Corporate presentation know about usDynamic Netsoft
 
Professional Resume Template for Software Developers
Professional Resume Template for Software DevelopersProfessional Resume Template for Software Developers
Professional Resume Template for Software DevelopersVinodh Ram
 
Steps To Getting Up And Running Quickly With MyTimeClock Employee Scheduling ...
Steps To Getting Up And Running Quickly With MyTimeClock Employee Scheduling ...Steps To Getting Up And Running Quickly With MyTimeClock Employee Scheduling ...
Steps To Getting Up And Running Quickly With MyTimeClock Employee Scheduling ...MyIntelliSource, Inc.
 
Software Quality Assurance Interview Questions
Software Quality Assurance Interview QuestionsSoftware Quality Assurance Interview Questions
Software Quality Assurance Interview QuestionsArshad QA
 
call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️
call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️
call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️Delhi Call girls
 
Tech Tuesday-Harness the Power of Effective Resource Planning with OnePlan’s ...
Tech Tuesday-Harness the Power of Effective Resource Planning with OnePlan’s ...Tech Tuesday-Harness the Power of Effective Resource Planning with OnePlan’s ...
Tech Tuesday-Harness the Power of Effective Resource Planning with OnePlan’s ...OnePlan Solutions
 
Optimizing AI for immediate response in Smart CCTV
Optimizing AI for immediate response in Smart CCTVOptimizing AI for immediate response in Smart CCTV
Optimizing AI for immediate response in Smart CCTVshikhaohhpro
 
Unveiling the Tech Salsa of LAMs with Janus in Real-Time Applications
Unveiling the Tech Salsa of LAMs with Janus in Real-Time ApplicationsUnveiling the Tech Salsa of LAMs with Janus in Real-Time Applications
Unveiling the Tech Salsa of LAMs with Janus in Real-Time ApplicationsAlberto González Trastoy
 
(Genuine) Escort Service Lucknow | Starting ₹,5K To @25k with A/C 🧑🏽‍❤️‍🧑🏻 89...
(Genuine) Escort Service Lucknow | Starting ₹,5K To @25k with A/C 🧑🏽‍❤️‍🧑🏻 89...(Genuine) Escort Service Lucknow | Starting ₹,5K To @25k with A/C 🧑🏽‍❤️‍🧑🏻 89...
(Genuine) Escort Service Lucknow | Starting ₹,5K To @25k with A/C 🧑🏽‍❤️‍🧑🏻 89...gurkirankumar98700
 
The Real-World Challenges of Medical Device Cybersecurity- Mitigating Vulnera...
The Real-World Challenges of Medical Device Cybersecurity- Mitigating Vulnera...The Real-World Challenges of Medical Device Cybersecurity- Mitigating Vulnera...
The Real-World Challenges of Medical Device Cybersecurity- Mitigating Vulnera...ICS
 
Shapes for Sharing between Graph Data Spaces - and Epistemic Querying of RDF-...
Shapes for Sharing between Graph Data Spaces - and Epistemic Querying of RDF-...Shapes for Sharing between Graph Data Spaces - and Epistemic Querying of RDF-...
Shapes for Sharing between Graph Data Spaces - and Epistemic Querying of RDF-...Steffen Staab
 
A Secure and Reliable Document Management System is Essential.docx
A Secure and Reliable Document Management System is Essential.docxA Secure and Reliable Document Management System is Essential.docx
A Secure and Reliable Document Management System is Essential.docxComplianceQuest1
 
How To Troubleshoot Collaboration Apps for the Modern Connected Worker
How To Troubleshoot Collaboration Apps for the Modern Connected WorkerHow To Troubleshoot Collaboration Apps for the Modern Connected Worker
How To Troubleshoot Collaboration Apps for the Modern Connected WorkerThousandEyes
 
HR Software Buyers Guide in 2024 - HRSoftware.com
HR Software Buyers Guide in 2024 - HRSoftware.comHR Software Buyers Guide in 2024 - HRSoftware.com
HR Software Buyers Guide in 2024 - HRSoftware.comFatema Valibhai
 
Try MyIntelliAccount Cloud Accounting Software As A Service Solution Risk Fre...
Try MyIntelliAccount Cloud Accounting Software As A Service Solution Risk Fre...Try MyIntelliAccount Cloud Accounting Software As A Service Solution Risk Fre...
Try MyIntelliAccount Cloud Accounting Software As A Service Solution Risk Fre...MyIntelliSource, Inc.
 
TECUNIQUE: Success Stories: IT Service provider
TECUNIQUE: Success Stories: IT Service providerTECUNIQUE: Success Stories: IT Service provider
TECUNIQUE: Success Stories: IT Service providermohitmore19
 
Reassessing the Bedrock of Clinical Function Models: An Examination of Large ...
Reassessing the Bedrock of Clinical Function Models: An Examination of Large ...Reassessing the Bedrock of Clinical Function Models: An Examination of Large ...
Reassessing the Bedrock of Clinical Function Models: An Examination of Large ...harshavardhanraghave
 
How To Use Server-Side Rendering with Nuxt.js
How To Use Server-Side Rendering with Nuxt.jsHow To Use Server-Side Rendering with Nuxt.js
How To Use Server-Side Rendering with Nuxt.jsAndolasoft Inc
 

Recently uploaded (20)

DNT_Corporate presentation know about us
DNT_Corporate presentation know about usDNT_Corporate presentation know about us
DNT_Corporate presentation know about us
 
Professional Resume Template for Software Developers
Professional Resume Template for Software DevelopersProfessional Resume Template for Software Developers
Professional Resume Template for Software Developers
 
Steps To Getting Up And Running Quickly With MyTimeClock Employee Scheduling ...
Steps To Getting Up And Running Quickly With MyTimeClock Employee Scheduling ...Steps To Getting Up And Running Quickly With MyTimeClock Employee Scheduling ...
Steps To Getting Up And Running Quickly With MyTimeClock Employee Scheduling ...
 
Software Quality Assurance Interview Questions
Software Quality Assurance Interview QuestionsSoftware Quality Assurance Interview Questions
Software Quality Assurance Interview Questions
 
call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️
call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️
call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️
 
Tech Tuesday-Harness the Power of Effective Resource Planning with OnePlan’s ...
Tech Tuesday-Harness the Power of Effective Resource Planning with OnePlan’s ...Tech Tuesday-Harness the Power of Effective Resource Planning with OnePlan’s ...
Tech Tuesday-Harness the Power of Effective Resource Planning with OnePlan’s ...
 
CHEAP Call Girls in Pushp Vihar (-DELHI )🔝 9953056974🔝(=)/CALL GIRLS SERVICE
CHEAP Call Girls in Pushp Vihar (-DELHI )🔝 9953056974🔝(=)/CALL GIRLS SERVICECHEAP Call Girls in Pushp Vihar (-DELHI )🔝 9953056974🔝(=)/CALL GIRLS SERVICE
CHEAP Call Girls in Pushp Vihar (-DELHI )🔝 9953056974🔝(=)/CALL GIRLS SERVICE
 
Optimizing AI for immediate response in Smart CCTV
Optimizing AI for immediate response in Smart CCTVOptimizing AI for immediate response in Smart CCTV
Optimizing AI for immediate response in Smart CCTV
 
Unveiling the Tech Salsa of LAMs with Janus in Real-Time Applications
Unveiling the Tech Salsa of LAMs with Janus in Real-Time ApplicationsUnveiling the Tech Salsa of LAMs with Janus in Real-Time Applications
Unveiling the Tech Salsa of LAMs with Janus in Real-Time Applications
 
(Genuine) Escort Service Lucknow | Starting ₹,5K To @25k with A/C 🧑🏽‍❤️‍🧑🏻 89...
(Genuine) Escort Service Lucknow | Starting ₹,5K To @25k with A/C 🧑🏽‍❤️‍🧑🏻 89...(Genuine) Escort Service Lucknow | Starting ₹,5K To @25k with A/C 🧑🏽‍❤️‍🧑🏻 89...
(Genuine) Escort Service Lucknow | Starting ₹,5K To @25k with A/C 🧑🏽‍❤️‍🧑🏻 89...
 
The Real-World Challenges of Medical Device Cybersecurity- Mitigating Vulnera...
The Real-World Challenges of Medical Device Cybersecurity- Mitigating Vulnera...The Real-World Challenges of Medical Device Cybersecurity- Mitigating Vulnera...
The Real-World Challenges of Medical Device Cybersecurity- Mitigating Vulnera...
 
Shapes for Sharing between Graph Data Spaces - and Epistemic Querying of RDF-...
Shapes for Sharing between Graph Data Spaces - and Epistemic Querying of RDF-...Shapes for Sharing between Graph Data Spaces - and Epistemic Querying of RDF-...
Shapes for Sharing between Graph Data Spaces - and Epistemic Querying of RDF-...
 
A Secure and Reliable Document Management System is Essential.docx
A Secure and Reliable Document Management System is Essential.docxA Secure and Reliable Document Management System is Essential.docx
A Secure and Reliable Document Management System is Essential.docx
 
How To Troubleshoot Collaboration Apps for the Modern Connected Worker
How To Troubleshoot Collaboration Apps for the Modern Connected WorkerHow To Troubleshoot Collaboration Apps for the Modern Connected Worker
How To Troubleshoot Collaboration Apps for the Modern Connected Worker
 
HR Software Buyers Guide in 2024 - HRSoftware.com
HR Software Buyers Guide in 2024 - HRSoftware.comHR Software Buyers Guide in 2024 - HRSoftware.com
HR Software Buyers Guide in 2024 - HRSoftware.com
 
Try MyIntelliAccount Cloud Accounting Software As A Service Solution Risk Fre...
Try MyIntelliAccount Cloud Accounting Software As A Service Solution Risk Fre...Try MyIntelliAccount Cloud Accounting Software As A Service Solution Risk Fre...
Try MyIntelliAccount Cloud Accounting Software As A Service Solution Risk Fre...
 
TECUNIQUE: Success Stories: IT Service provider
TECUNIQUE: Success Stories: IT Service providerTECUNIQUE: Success Stories: IT Service provider
TECUNIQUE: Success Stories: IT Service provider
 
Reassessing the Bedrock of Clinical Function Models: An Examination of Large ...
Reassessing the Bedrock of Clinical Function Models: An Examination of Large ...Reassessing the Bedrock of Clinical Function Models: An Examination of Large ...
Reassessing the Bedrock of Clinical Function Models: An Examination of Large ...
 
Vip Call Girls Noida ➡️ Delhi ➡️ 9999965857 No Advance 24HRS Live
Vip Call Girls Noida ➡️ Delhi ➡️ 9999965857 No Advance 24HRS LiveVip Call Girls Noida ➡️ Delhi ➡️ 9999965857 No Advance 24HRS Live
Vip Call Girls Noida ➡️ Delhi ➡️ 9999965857 No Advance 24HRS Live
 
How To Use Server-Side Rendering with Nuxt.js
How To Use Server-Side Rendering with Nuxt.jsHow To Use Server-Side Rendering with Nuxt.js
How To Use Server-Side Rendering with Nuxt.js
 

Elasticsearch

  • 1. Elasticsearch  Node  It refers to a single running instance of Elasticsearch.    Cluster [Database in RDBMS analogy]  It is a collection of one or more nodes.     Index [Table in RDBMS analogy]  It is a collection of different types of documents and their properties. Index also uses  the concept of shards to improve the performance.    Document [Row in RDBMS analogy]  It is a collection of fields in a specific manner defined in JSON format. Every document                                 belongs to a type and resides inside an index. Every document is associated with a                               unique identifier called the UID.    Shard  Indexes are horizontally subdivided into shards. This means each shard contains all                         the properties of the document but contains less number of JSON objects than index.                             The horizontal separation makes shard an independent node, which can be store in                           any node. Primary shard is the original horizontal part of an index and then these                               primary shards are replicated into replica shards.    Replicas  Elasticsearch allows a user to create replicas of their indexes and shards. Replication                           not only helps in increasing the availability of data in case of failure, but also improves                                 the performance of searching by carrying out a parallel search operation in these                           replicas.   
  • 2. URLs  Elasticsearch ​http://localhost:9200  Kibana ​http://localhost:5601      Syntax of REST API to query Elasticsearch using Query DSL (Domain Specific  Language)    <HTTP_VERB> <api>/<command>  {  JSON Body  }    GET _cluster/health      1. Create an Index  PUT students  {  "settings": {  "index": {  "number_of_shards": 1,  "number_of_replicas": 0  }  }  }    2. Delete in Index  DELETE students      3. Add Documents one by one  PUT /students/student/1  {  "name": "Pratyush",  "roll": 10,  "city": "Gurgaon",  "state": "Haryana",  "desc": "Pratyush knows C, Java and PHP"  }       
  • 3. PUT /students/student/2  {  "name": "Dushyant",  "roll": 12,  "city": "Rewari",  "state": "Haryana",  "desc": "Dushyant knows C and Java"  }    PUT /students/student/3  {  "name": "Yogesh",  "roll": 15,  "city": "Bharatpur",  "state": "Rajasthan",  "desc": "Yogesh knows Java"  }    4. Bulk Add documents (Linux Command)  curl -H "Content-Type: application/json" -XPOST  "http://localhost:9200/students/_bulk" --data-binary "@students.json"    5. View documents by Id  GET /students/student/1    6. Update a document  PUT /students/student/1  {  "name": "Pratyush Majumdar",  "roll": 10,  "city": "Gurgaon",  "state": "Haryana"  "desc": "Pratyush knows C, Java and PHP"  }    7. Get settings of any index  GET /students/_settings             
  • 4. Search API    GET /students/_search  {  "query":{  "match_all":{}  }  }    GET students/student/_search  {  "query":{  "query_string":{  "query":"Java"  }  }  }    GET /students/student/_search  {  "query": {  "query_string": {  "default_field": "state",  "query": "Haryana"  }  }  }                                 
  • 5. Completion Suggester    1. Mapping query    PUT phones  {  "mappings": {  "phone" : {  "properties" : {  "suggest" : {  "type" : "completion"  },  "title" : {  "type": "keyword"  }  }  }  }  }      2. Add Data with input  PUT phones/phone/1  {  "name" : "Apple iPhone 12 pro max",  "suggest" : {  "input": [   "Apple",   "iPhone",   "Apple iPhone",  "iPhone 12",  "pro max",  "Apple iPhone 12 pro max"  ],  "weight" : 12  }  }             
  • 6. PUT phones/phone/2  {  "name" : "Apple iPhone 11 pro max",  "suggest" : {  "input": [   "Apple",   "iPhone",   "Apple iPhone",  "iPhone 11",  "pro max",  "Apple iPhone 11 pro max"  ],  "weight" : 11  }  }    PUT phones/phone/3  {  "name" : "Apple iPhone X",  "suggest" : {  "input": [   "Apple",   "iPhone",   "Apple iPhone",  "iPhone X",  "Apple iPhone X"  ],  "weight" : 10  }  }    PUT phones/phone/4  {  "name" : "Apple iPhone 9 Plus",  "suggest" : {  "input": [   "Apple",   "iPhone",   "Apple iPhone",  "iPhone 9",  "9 Plus",  "Apple iPhone 9 Plus"  ], 
  • 7. "weight" : 9  }  }          3. Search using prefix Match  GET phones/_search  {  "suggest": {  "song-suggest" : {  "prefix" : "i",   "completion" : {   "field" : "suggest"  }  }  }  }    4. Search using prefix Match with Fuzzy-ness of 2 (For miss-spelling)  GET phones/_search  {  "suggest": {  "song-suggest" : {  "prefix" : "Appel",   "completion" : {   "field" : "suggest",  "fuzzy" : {  "fuzziness" : 2  }  }  }  }  }