SlideShare a Scribd company logo
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

PPTX
Elasticsearch Meta Fields
PPTX
Introduction to Elasticsearch Mapping
PPTX
Elasticsearch Field Data Types
PPTX
Elasticsearch: Removal of types
PPTX
Postgre sql data types
PDF
Annotating Search Results from Web Databases
PDF
Indexing techniques
Elasticsearch Meta Fields
Introduction to Elasticsearch Mapping
Elasticsearch Field Data Types
Elasticsearch: Removal of types
Postgre sql data types
Annotating Search Results from Web Databases
Indexing techniques

What's hot (20)

PPTX
B tree
PPTX
Indexing
PPT
Data indexing presentation
PPTX
Pattern matching & file input and output
PPTX
Data exchange over internet (XML vs JSON)
PPT
PPT
Zhishi.me - Weaving Chinese Linking Open Data
ODP
Dutch Government Business Case
DOCX
Annotating search results from web databases
PPTX
Introduction to XML
PPT
Database structure
PPTX
Db sys concept
PPT
File organization 1
PPTX
An hour with Database and SQL
PPS
How web searching engines work
PDF
Xml databases
PPT
Inverted index
PPTX
Data structure
B tree
Indexing
Data indexing presentation
Pattern matching & file input and output
Data exchange over internet (XML vs JSON)
Zhishi.me - Weaving Chinese Linking Open Data
Dutch Government Business Case
Annotating search results from web databases
Introduction to XML
Database structure
Db sys concept
File organization 1
An hour with Database and SQL
How web searching engines work
Xml databases
Inverted index
Data structure
Ad

Similar to Introduction to Elasticsearch Searching (20)

PPTX
How search engines work Anand Saini
PPTX
Building an unstructured data management solution with elastic search and ama...
PPT
The Art Of Searching
PPTX
Philly PHP: April '17 Elastic Search Introduction by Aditya Bhamidpati
PPT
Phrase based Indexing and Information Retrieval
PPT
Searching techniques
PPT
Searching techniques
PDF
Chapter 6 Query Language .pdf
PPTX
Updated-Index-Data-Structures.pptx inndetail
PDF
Getting started with looking up metadata
PPTX
information retrieval in artificial intelligence
PPT
Xml and webdata
PPT
Xml and webdata
PPT
Xml and webdata
PPT
Xml and webdata
PPT
Xml and webdata
PPT
Xml and webdata
PPT
Xml and webdata
PPT
Electronic Databases
How search engines work Anand Saini
Building an unstructured data management solution with elastic search and ama...
The Art Of Searching
Philly PHP: April '17 Elastic Search Introduction by Aditya Bhamidpati
Phrase based Indexing and Information Retrieval
Searching techniques
Searching techniques
Chapter 6 Query Language .pdf
Updated-Index-Data-Structures.pptx inndetail
Getting started with looking up metadata
information retrieval in artificial intelligence
Xml and webdata
Xml and webdata
Xml and webdata
Xml and webdata
Xml and webdata
Xml and webdata
Xml and webdata
Electronic Databases
Ad

Recently uploaded (20)

PPTX
Programs and apps: productivity, graphics, security and other tools
PPTX
MYSQL Presentation for SQL database connectivity
PPTX
Big Data Technologies - Introduction.pptx
PDF
Unlocking AI with Model Context Protocol (MCP)
PDF
Agricultural_Statistics_at_a_Glance_2022_0.pdf
PPTX
Effective Security Operations Center (SOC) A Modern, Strategic, and Threat-In...
PDF
Empathic Computing: Creating Shared Understanding
PDF
Chapter 3 Spatial Domain Image Processing.pdf
PPT
Teaching material agriculture food technology
PDF
MIND Revenue Release Quarter 2 2025 Press Release
PPTX
Digital-Transformation-Roadmap-for-Companies.pptx
PDF
Network Security Unit 5.pdf for BCA BBA.
PPTX
ACSFv1EN-58255 AWS Academy Cloud Security Foundations.pptx
PDF
Diabetes mellitus diagnosis method based random forest with bat algorithm
PPTX
Cloud computing and distributed systems.
PDF
Machine learning based COVID-19 study performance prediction
PDF
Dropbox Q2 2025 Financial Results & Investor Presentation
PPTX
KOM of Painting work and Equipment Insulation REV00 update 25-dec.pptx
PDF
Review of recent advances in non-invasive hemoglobin estimation
PDF
Electronic commerce courselecture one. Pdf
Programs and apps: productivity, graphics, security and other tools
MYSQL Presentation for SQL database connectivity
Big Data Technologies - Introduction.pptx
Unlocking AI with Model Context Protocol (MCP)
Agricultural_Statistics_at_a_Glance_2022_0.pdf
Effective Security Operations Center (SOC) A Modern, Strategic, and Threat-In...
Empathic Computing: Creating Shared Understanding
Chapter 3 Spatial Domain Image Processing.pdf
Teaching material agriculture food technology
MIND Revenue Release Quarter 2 2025 Press Release
Digital-Transformation-Roadmap-for-Companies.pptx
Network Security Unit 5.pdf for BCA BBA.
ACSFv1EN-58255 AWS Academy Cloud Security Foundations.pptx
Diabetes mellitus diagnosis method based random forest with bat algorithm
Cloud computing and distributed systems.
Machine learning based COVID-19 study performance prediction
Dropbox Q2 2025 Financial Results & Investor Presentation
KOM of Painting work and Equipment Insulation REV00 update 25-dec.pptx
Review of recent advances in non-invasive hemoglobin estimation
Electronic commerce courselecture one. 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