SlideShare a Scribd company logo
1 of 13
INTRODUCTION TO
SEARCHINGby Bo Andersen - codingexplained.com
OUTLINE
➤ Relevancy & scoring
➤ Ways of searching
➤ Query string
➤ Query DSL
➤ Types of queries
➤ Leaf & compound
➤ Full text
➤ Term level
➤ Compound
RELEVANCY & SCORING
➤ To rank documents for a query, a score is calculated for each document that matches
a query
➤ The higher the score, the more relevant the document is to the search query
➤ Queries in query context affect the scores of matching documents
➤ "How well does the document match?"
➤ Queries in filter context do not affect the scores of matching documents
➤ "Does the document match"
WAYS OF
SEARCHING
QUERY STRING
➤ Search by sending search parameters through the REST request URI (as query
parameters)
➤ Used for simple queries and ad-hoc queries on the command line
➤ Also supports advanced queries
➤ Example
➤ GET http://localhost:9200/ecommerce/product/_search?q=pasta
QUERY DSL
➤ Search by defining queries within the request body in JSON
➤ Supports more features than the query string approach
➤ Used for more advanced queries
➤ Often easier to read, as queries are defined in JSON
GET http://localhost:9200/ecommerce/product/_search
{
"query": {
"match": {
"name": "pasta"
}
}
}
TYPES OF
QUERIES
LEAF & COMPOUND QUERIES
➤ Leaf
➤ Look for particular values in particular fields, for instance "pasta" in product names
➤ Can be used by themselves within a query, without being part of a compound query
➤ Can also be used within compound queries to construct more advanced queries
➤ Compound
➤ Wrap leaf clauses or even other compound query clauses
➤ Used to combine multiple queries in a logical fashion (usually with boolean logic)
➤ Can also be used to alter the behavior of queries
FULL TEXT
➤ Used for running full text queries on full text fields
➤ E.g. a product name or description
➤ Values are analyzed when adding documents or modifying values
➤ E.g. removing stop words, tokenizing and lowercasing
➤ Will apply each field's analyzer to the query string before executing
TERM LEVEL
➤ Used for exact matching of values
➤ Usually used for structured data like numbers and dates, rather than full text fields
➤ E.g. finding persons born between year 1980 and 2000
➤ Search queries are not analyzed before executing
JOINING QUERIES
➤ Performing joins in a distributed system is expensive
➤ Elasticsearch offers two forms of joins that are designed to scale horizontally
➤ Nested query
➤ Documents may contains fields of type nested with arrays of objects
➤ Each object can be queried with the nested query as an independent document
➤ has_child and has_parent queries
➤ A parent-child relationship can exist between two document types within a single index
➤ The has_child query returns parent documents whose child documents match the query
➤ The has_parent query returns child documents whose parent document matches the
query
GEO QUERIES
➤ Elasticsearch supports two types of geo fields
➤ geo_point (lat/lon pairs)
➤ geo_shape (points, lines, circles, polygons, etc.)
➤ Various geo queries use these fields to perform geographical searches
➤ E.g. finding points of interest near GPS coordinates
THANK YOU FOR
WATCHING!

More Related Content

What's hot (20)

B tree
B treeB tree
B tree
 
Indexing
IndexingIndexing
Indexing
 
Data indexing presentation
Data indexing presentationData indexing presentation
Data indexing presentation
 
Pattern matching & file input and output
Pattern matching & file input and outputPattern matching & file input and output
Pattern matching & file input and output
 
Data exchange over internet (XML vs JSON)
Data exchange over internet (XML vs JSON)Data exchange over internet (XML vs JSON)
Data exchange over internet (XML vs JSON)
 
Files
FilesFiles
Files
 
Jhu Week 6
Jhu Week 6Jhu Week 6
Jhu Week 6
 
Zhishi.me - Weaving Chinese Linking Open Data
Zhishi.me - Weaving Chinese Linking Open DataZhishi.me - Weaving Chinese Linking Open Data
Zhishi.me - Weaving Chinese Linking Open Data
 
Dutch Government Business Case
Dutch Government Business CaseDutch Government Business Case
Dutch Government Business Case
 
Annotating search results from web databases
Annotating search results from web databasesAnnotating search results from web databases
Annotating search results from web databases
 
Introduction to XML
Introduction to XMLIntroduction to XML
Introduction to XML
 
Database structure
Database structureDatabase structure
Database structure
 
DATA BASE MODEL Rohini
DATA BASE MODEL RohiniDATA BASE MODEL Rohini
DATA BASE MODEL Rohini
 
Db sys concept
Db sys conceptDb sys concept
Db sys concept
 
File organization 1
File organization 1File organization 1
File organization 1
 
An hour with Database and SQL
An hour with Database and SQLAn hour with Database and SQL
An hour with Database and SQL
 
How web searching engines work
How web searching engines workHow web searching engines work
How web searching engines work
 
Xml databases
Xml databasesXml databases
Xml databases
 
Inverted index
Inverted indexInverted index
Inverted index
 
Data structure
Data structureData structure
Data structure
 

Similar to Introduction to Elasticsearch Searching

How search engines work Anand Saini
How search engines work Anand SainiHow search engines work Anand Saini
How search engines work Anand SainiDr,Saini Anand
 
Building an unstructured data management solution with elastic search and ama...
Building an unstructured data management solution with elastic search and ama...Building an unstructured data management solution with elastic search and ama...
Building an unstructured data management solution with elastic search and ama...mobiusservices
 
The Art Of Searching
The Art Of SearchingThe Art Of Searching
The Art Of SearchingPaul Neal
 
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 BhamidpatiRobert Calcavecchia
 
Phrase based Indexing and Information Retrieval
Phrase based Indexing and Information RetrievalPhrase based Indexing and Information Retrieval
Phrase based Indexing and Information RetrievalBala Abirami
 
Chapter 6 Query Language .pdf
Chapter 6 Query Language .pdfChapter 6 Query Language .pdf
Chapter 6 Query Language .pdfHabtamu100
 
Getting started with looking up metadata
Getting started with looking up metadata Getting started with looking up metadata
Getting started with looking up metadata Crossref
 
information retrieval in artificial intelligence
information retrieval in artificial intelligenceinformation retrieval in artificial intelligence
information retrieval in artificial intelligencePriyadharshiniG41
 
Xml and webdata
Xml and webdataXml and webdata
Xml and webdataFraboni Ec
 
Xml and webdata
Xml and webdataXml and webdata
Xml and webdataJames Wong
 
Elasticsearch V/s Relational Database
Elasticsearch V/s Relational DatabaseElasticsearch V/s Relational Database
Elasticsearch V/s Relational DatabaseRicha Budhraja
 

Similar to Introduction to Elasticsearch Searching (20)

How search engines work Anand Saini
How search engines work Anand SainiHow search engines work Anand Saini
How search engines work Anand Saini
 
Building an unstructured data management solution with elastic search and ama...
Building an unstructured data management solution with elastic search and ama...Building an unstructured data management solution with elastic search and ama...
Building an unstructured data management solution with elastic search and ama...
 
The Art Of Searching
The Art Of SearchingThe Art Of Searching
The Art Of Searching
 
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
 
Phrase based Indexing and Information Retrieval
Phrase based Indexing and Information RetrievalPhrase based Indexing and Information Retrieval
Phrase based Indexing and Information Retrieval
 
IR
IRIR
IR
 
Searching techniques
Searching techniquesSearching techniques
Searching techniques
 
Searching techniques
Searching techniquesSearching techniques
Searching techniques
 
Chapter 6 Query Language .pdf
Chapter 6 Query Language .pdfChapter 6 Query Language .pdf
Chapter 6 Query Language .pdf
 
Getting started with looking up metadata
Getting started with looking up metadata Getting started with looking up metadata
Getting started with looking up metadata
 
information retrieval in artificial intelligence
information retrieval in artificial intelligenceinformation retrieval in artificial intelligence
information retrieval in artificial intelligence
 
Xml and webdata
Xml and webdataXml and webdata
Xml and webdata
 
Xml and webdata
Xml and webdataXml and webdata
Xml and webdata
 
Xml and webdata
Xml and webdataXml and webdata
Xml and webdata
 
Xml and webdata
Xml and webdataXml and webdata
Xml and webdata
 
Xml and webdata
Xml and webdataXml and webdata
Xml and webdata
 
Xml and webdata
Xml and webdataXml and webdata
Xml and webdata
 
Xml and webdata
Xml and webdataXml and webdata
Xml and webdata
 
Electronic Databases
Electronic DatabasesElectronic Databases
Electronic Databases
 
Elasticsearch V/s Relational Database
Elasticsearch V/s Relational DatabaseElasticsearch V/s Relational Database
Elasticsearch V/s Relational Database
 

Recently uploaded

CORS (Kitworks Team Study 양다윗 발표자료 240510)
CORS (Kitworks Team Study 양다윗 발표자료 240510)CORS (Kitworks Team Study 양다윗 발표자료 240510)
CORS (Kitworks Team Study 양다윗 발표자료 240510)Wonjun Hwang
 
Vector Search @ sw2con for slideshare.pptx
Vector Search @ sw2con for slideshare.pptxVector Search @ sw2con for slideshare.pptx
Vector Search @ sw2con for slideshare.pptxjbellis
 
The Zero-ETL Approach: Enhancing Data Agility and Insight
The Zero-ETL Approach: Enhancing Data Agility and InsightThe Zero-ETL Approach: Enhancing Data Agility and Insight
The Zero-ETL Approach: Enhancing Data Agility and InsightSafe Software
 
JohnPollard-hybrid-app-RailsConf2024.pptx
JohnPollard-hybrid-app-RailsConf2024.pptxJohnPollard-hybrid-app-RailsConf2024.pptx
JohnPollard-hybrid-app-RailsConf2024.pptxJohnPollard37
 
Top 10 CodeIgniter Development Companies
Top 10 CodeIgniter Development CompaniesTop 10 CodeIgniter Development Companies
Top 10 CodeIgniter Development CompaniesTopCSSGallery
 
Microsoft CSP Briefing Pre-Engagement - Questionnaire
Microsoft CSP Briefing Pre-Engagement - QuestionnaireMicrosoft CSP Briefing Pre-Engagement - Questionnaire
Microsoft CSP Briefing Pre-Engagement - QuestionnaireExakis Nelite
 
Event-Driven Architecture Masterclass: Challenges in Stream Processing
Event-Driven Architecture Masterclass: Challenges in Stream ProcessingEvent-Driven Architecture Masterclass: Challenges in Stream Processing
Event-Driven Architecture Masterclass: Challenges in Stream ProcessingScyllaDB
 
Harnessing Passkeys in the Battle Against AI-Powered Cyber Threats.pptx
Harnessing Passkeys in the Battle Against AI-Powered Cyber Threats.pptxHarnessing Passkeys in the Battle Against AI-Powered Cyber Threats.pptx
Harnessing Passkeys in the Battle Against AI-Powered Cyber Threats.pptxFIDO Alliance
 
How we scaled to 80K users by doing nothing!.pdf
How we scaled to 80K users by doing nothing!.pdfHow we scaled to 80K users by doing nothing!.pdf
How we scaled to 80K users by doing nothing!.pdfSrushith Repakula
 
Design and Development of a Provenance Capture Platform for Data Science
Design and Development of a Provenance Capture Platform for Data ScienceDesign and Development of a Provenance Capture Platform for Data Science
Design and Development of a Provenance Capture Platform for Data SciencePaolo Missier
 
Hyatt driving innovation and exceptional customer experiences with FIDO passw...
Hyatt driving innovation and exceptional customer experiences with FIDO passw...Hyatt driving innovation and exceptional customer experiences with FIDO passw...
Hyatt driving innovation and exceptional customer experiences with FIDO passw...FIDO Alliance
 
How to Check GPS Location with a Live Tracker in Pakistan
How to Check GPS Location with a Live Tracker in PakistanHow to Check GPS Location with a Live Tracker in Pakistan
How to Check GPS Location with a Live Tracker in Pakistandanishmna97
 
Easier, Faster, and More Powerful – Alles Neu macht der Mai -Wir durchleuchte...
Easier, Faster, and More Powerful – Alles Neu macht der Mai -Wir durchleuchte...Easier, Faster, and More Powerful – Alles Neu macht der Mai -Wir durchleuchte...
Easier, Faster, and More Powerful – Alles Neu macht der Mai -Wir durchleuchte...panagenda
 
Introduction to FIDO Authentication and Passkeys.pptx
Introduction to FIDO Authentication and Passkeys.pptxIntroduction to FIDO Authentication and Passkeys.pptx
Introduction to FIDO Authentication and Passkeys.pptxFIDO Alliance
 
WebRTC and SIP not just audio and video @ OpenSIPS 2024
WebRTC and SIP not just audio and video @ OpenSIPS 2024WebRTC and SIP not just audio and video @ OpenSIPS 2024
WebRTC and SIP not just audio and video @ OpenSIPS 2024Lorenzo Miniero
 
Generative AI Use Cases and Applications.pdf
Generative AI Use Cases and Applications.pdfGenerative AI Use Cases and Applications.pdf
Generative AI Use Cases and Applications.pdfalexjohnson7307
 
ERP Contender Series: Acumatica vs. Sage Intacct
ERP Contender Series: Acumatica vs. Sage IntacctERP Contender Series: Acumatica vs. Sage Intacct
ERP Contender Series: Acumatica vs. Sage IntacctBrainSell Technologies
 
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 presentationyogeshlabana357357
 
WebAssembly is Key to Better LLM Performance
WebAssembly is Key to Better LLM PerformanceWebAssembly is Key to Better LLM Performance
WebAssembly is Key to Better LLM PerformanceSamy Fodil
 
“Iamnobody89757” Understanding the Mysterious of Digital Identity.pdf
“Iamnobody89757” Understanding the Mysterious of Digital Identity.pdf“Iamnobody89757” Understanding the Mysterious of Digital Identity.pdf
“Iamnobody89757” Understanding the Mysterious of Digital Identity.pdfMuhammad Subhan
 

Recently uploaded (20)

CORS (Kitworks Team Study 양다윗 발표자료 240510)
CORS (Kitworks Team Study 양다윗 발표자료 240510)CORS (Kitworks Team Study 양다윗 발표자료 240510)
CORS (Kitworks Team Study 양다윗 발표자료 240510)
 
Vector Search @ sw2con for slideshare.pptx
Vector Search @ sw2con for slideshare.pptxVector Search @ sw2con for slideshare.pptx
Vector Search @ sw2con for slideshare.pptx
 
The Zero-ETL Approach: Enhancing Data Agility and Insight
The Zero-ETL Approach: Enhancing Data Agility and InsightThe Zero-ETL Approach: Enhancing Data Agility and Insight
The Zero-ETL Approach: Enhancing Data Agility and Insight
 
JohnPollard-hybrid-app-RailsConf2024.pptx
JohnPollard-hybrid-app-RailsConf2024.pptxJohnPollard-hybrid-app-RailsConf2024.pptx
JohnPollard-hybrid-app-RailsConf2024.pptx
 
Top 10 CodeIgniter Development Companies
Top 10 CodeIgniter Development CompaniesTop 10 CodeIgniter Development Companies
Top 10 CodeIgniter Development Companies
 
Microsoft CSP Briefing Pre-Engagement - Questionnaire
Microsoft CSP Briefing Pre-Engagement - QuestionnaireMicrosoft CSP Briefing Pre-Engagement - Questionnaire
Microsoft CSP Briefing Pre-Engagement - Questionnaire
 
Event-Driven Architecture Masterclass: Challenges in Stream Processing
Event-Driven Architecture Masterclass: Challenges in Stream ProcessingEvent-Driven Architecture Masterclass: Challenges in Stream Processing
Event-Driven Architecture Masterclass: Challenges in Stream Processing
 
Harnessing Passkeys in the Battle Against AI-Powered Cyber Threats.pptx
Harnessing Passkeys in the Battle Against AI-Powered Cyber Threats.pptxHarnessing Passkeys in the Battle Against AI-Powered Cyber Threats.pptx
Harnessing Passkeys in the Battle Against AI-Powered Cyber Threats.pptx
 
How we scaled to 80K users by doing nothing!.pdf
How we scaled to 80K users by doing nothing!.pdfHow we scaled to 80K users by doing nothing!.pdf
How we scaled to 80K users by doing nothing!.pdf
 
Design and Development of a Provenance Capture Platform for Data Science
Design and Development of a Provenance Capture Platform for Data ScienceDesign and Development of a Provenance Capture Platform for Data Science
Design and Development of a Provenance Capture Platform for Data Science
 
Hyatt driving innovation and exceptional customer experiences with FIDO passw...
Hyatt driving innovation and exceptional customer experiences with FIDO passw...Hyatt driving innovation and exceptional customer experiences with FIDO passw...
Hyatt driving innovation and exceptional customer experiences with FIDO passw...
 
How to Check GPS Location with a Live Tracker in Pakistan
How to Check GPS Location with a Live Tracker in PakistanHow to Check GPS Location with a Live Tracker in Pakistan
How to Check GPS Location with a Live Tracker in Pakistan
 
Easier, Faster, and More Powerful – Alles Neu macht der Mai -Wir durchleuchte...
Easier, Faster, and More Powerful – Alles Neu macht der Mai -Wir durchleuchte...Easier, Faster, and More Powerful – Alles Neu macht der Mai -Wir durchleuchte...
Easier, Faster, and More Powerful – Alles Neu macht der Mai -Wir durchleuchte...
 
Introduction to FIDO Authentication and Passkeys.pptx
Introduction to FIDO Authentication and Passkeys.pptxIntroduction to FIDO Authentication and Passkeys.pptx
Introduction to FIDO Authentication and Passkeys.pptx
 
WebRTC and SIP not just audio and video @ OpenSIPS 2024
WebRTC and SIP not just audio and video @ OpenSIPS 2024WebRTC and SIP not just audio and video @ OpenSIPS 2024
WebRTC and SIP not just audio and video @ OpenSIPS 2024
 
Generative AI Use Cases and Applications.pdf
Generative AI Use Cases and Applications.pdfGenerative AI Use Cases and Applications.pdf
Generative AI Use Cases and Applications.pdf
 
ERP Contender Series: Acumatica vs. Sage Intacct
ERP Contender Series: Acumatica vs. Sage IntacctERP Contender Series: Acumatica vs. Sage Intacct
ERP Contender Series: Acumatica vs. Sage Intacct
 
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
 
WebAssembly is Key to Better LLM Performance
WebAssembly is Key to Better LLM PerformanceWebAssembly is Key to Better LLM Performance
WebAssembly is Key to Better LLM Performance
 
“Iamnobody89757” Understanding the Mysterious of Digital Identity.pdf
“Iamnobody89757” Understanding the Mysterious of Digital Identity.pdf“Iamnobody89757” Understanding the Mysterious of Digital Identity.pdf
“Iamnobody89757” Understanding the Mysterious of Digital Identity.pdf
 

Introduction to Elasticsearch Searching

  • 1. INTRODUCTION TO SEARCHINGby Bo Andersen - codingexplained.com
  • 2. OUTLINE ➤ Relevancy & scoring ➤ Ways of searching ➤ Query string ➤ Query DSL ➤ Types of queries ➤ Leaf & compound ➤ Full text ➤ Term level ➤ Compound
  • 3. RELEVANCY & SCORING ➤ To rank documents for a query, a score is calculated for each document that matches a query ➤ The higher the score, the more relevant the document is to the search query ➤ Queries in query context affect the scores of matching documents ➤ "How well does the document match?" ➤ Queries in filter context do not affect the scores of matching documents ➤ "Does the document match"
  • 5. QUERY STRING ➤ Search by sending search parameters through the REST request URI (as query parameters) ➤ Used for simple queries and ad-hoc queries on the command line ➤ Also supports advanced queries ➤ Example ➤ GET http://localhost:9200/ecommerce/product/_search?q=pasta
  • 6. QUERY DSL ➤ Search by defining queries within the request body in JSON ➤ Supports more features than the query string approach ➤ Used for more advanced queries ➤ Often easier to read, as queries are defined in JSON GET http://localhost:9200/ecommerce/product/_search { "query": { "match": { "name": "pasta" } } }
  • 8. LEAF & COMPOUND QUERIES ➤ Leaf ➤ Look for particular values in particular fields, for instance "pasta" in product names ➤ Can be used by themselves within a query, without being part of a compound query ➤ Can also be used within compound queries to construct more advanced queries ➤ Compound ➤ Wrap leaf clauses or even other compound query clauses ➤ Used to combine multiple queries in a logical fashion (usually with boolean logic) ➤ Can also be used to alter the behavior of queries
  • 9. FULL TEXT ➤ Used for running full text queries on full text fields ➤ E.g. a product name or description ➤ Values are analyzed when adding documents or modifying values ➤ E.g. removing stop words, tokenizing and lowercasing ➤ Will apply each field's analyzer to the query string before executing
  • 10. TERM LEVEL ➤ Used for exact matching of values ➤ Usually used for structured data like numbers and dates, rather than full text fields ➤ E.g. finding persons born between year 1980 and 2000 ➤ Search queries are not analyzed before executing
  • 11. JOINING QUERIES ➤ Performing joins in a distributed system is expensive ➤ Elasticsearch offers two forms of joins that are designed to scale horizontally ➤ Nested query ➤ Documents may contains fields of type nested with arrays of objects ➤ Each object can be queried with the nested query as an independent document ➤ has_child and has_parent queries ➤ A parent-child relationship can exist between two document types within a single index ➤ The has_child query returns parent documents whose child documents match the query ➤ The has_parent query returns child documents whose parent document matches the query
  • 12. GEO QUERIES ➤ Elasticsearch supports two types of geo fields ➤ geo_point (lat/lon pairs) ➤ geo_shape (points, lines, circles, polygons, etc.) ➤ Various geo queries use these fields to perform geographical searches ➤ E.g. finding points of interest near GPS coordinates