Top Banner
Arthur Gimpel Solutions Architect Elasticsearch SQL Webinar
18

Elasticsearch SQL Webinar · 2020-06-07 · Elasticsearch SQL RDBMS Terminological Differences Relational Databases (RDBMS) Elasticsearch SQL Column Field Row Document Table

Jul 04, 2020

Download

Documents

dariahiddleston
Welcome message from author
This document is posted to help you gain knowledge. Please leave a comment to let me know what you think about it! Share it to your friends and learn new things together.
Transcript
Page 1: Elasticsearch SQL Webinar · 2020-06-07 · Elasticsearch SQL <> RDBMS Terminological Differences Relational Databases (RDBMS) Elasticsearch SQL Column Field Row Document Table

Arthur GimpelSolutions Architect

Elasticsearch SQL Webinar

Page 2: Elasticsearch SQL Webinar · 2020-06-07 · Elasticsearch SQL <> RDBMS Terminological Differences Relational Databases (RDBMS) Elasticsearch SQL Column Field Row Document Table

Agenda

What is Elasticsearch SQL?1

Aggregations3

Geographic queries 4

Text operators and relevancy2

Page 3: Elasticsearch SQL Webinar · 2020-06-07 · Elasticsearch SQL <> RDBMS Terminological Differences Relational Databases (RDBMS) Elasticsearch SQL Column Field Row Document Table

What is Elasticsearch SQL

• SQL interpreter for Elasticsearch queries

• Based on Elasticsearch API’s & ANSI SQL

• Lightweight and scalable

SQL Interface to Elasticsearch

JDBC

ODBC

REST API

CLI

Page 4: Elasticsearch SQL Webinar · 2020-06-07 · Elasticsearch SQL <> RDBMS Terminological Differences Relational Databases (RDBMS) Elasticsearch SQL Column Field Row Document Table

Elasticsearch SQL <> RDBMSTerminological Differences

Relational Databases (RDBMS) Elasticsearch SQL

Column Field

Row Document

Table Index

View Alias

Schema - (Security can enforce “schema”)

Database / Catalog -

Instance / Cluster Cluster / Clusters (Federated via CCS)

Page 5: Elasticsearch SQL Webinar · 2020-06-07 · Elasticsearch SQL <> RDBMS Terminological Differences Relational Databases (RDBMS) Elasticsearch SQL Column Field Row Document Table

Elasticsearch SQL ExecutionSQL Interpreter Internals

SQL Query Unresolved AST

Resolved / Logical Plan

Optimized Plan Physical Plan Client

Results

Analysis PlanningParsing Execution

Query DSL

Page 6: Elasticsearch SQL Webinar · 2020-06-07 · Elasticsearch SQL <> RDBMS Terminological Differences Relational Databases (RDBMS) Elasticsearch SQL Column Field Row Document Table

6

Demo

Page 7: Elasticsearch SQL Webinar · 2020-06-07 · Elasticsearch SQL <> RDBMS Terminological Differences Relational Databases (RDBMS) Elasticsearch SQL Column Field Row Document Table

Agenda

What is Elasticsearch SQL?1

Aggregations3

Geographic queries4

Text operators and relevancy2

Page 8: Elasticsearch SQL Webinar · 2020-06-07 · Elasticsearch SQL <> RDBMS Terminological Differences Relational Databases (RDBMS) Elasticsearch SQL Column Field Row Document Table

Text Operators and Relevancy

• Within the WHERE clause there are two predicates made for full text:‒ MATCH (field(s) to match, matching text, optional parameters)

‒ QUERY (query_string, optional parameters)

• The SCORE() function is used to project the result of the scoring. Can be used in the scope of SELECT, ORDER BY clauses

Fulltext Search with Elasticsearch SQL

"match" : { "full_name" : { "query" : "arthur gimpel", "operator" : "AND“ }}

SELECT …WHERE MATCH('full_name', 'arthur gimpel', ‘operator=and’);

"multi_match" : { "query" : "Lee", "fields" : [ "first_name", "last_name^2.0"] }

SELECT …WHERE MATCH(‘first_name, last_name^2.0’ , ‘Lee’)

Page 9: Elasticsearch SQL Webinar · 2020-06-07 · Elasticsearch SQL <> RDBMS Terminological Differences Relational Databases (RDBMS) Elasticsearch SQL Column Field Row Document Table

9

Demo

Page 10: Elasticsearch SQL Webinar · 2020-06-07 · Elasticsearch SQL <> RDBMS Terminological Differences Relational Databases (RDBMS) Elasticsearch SQL Column Field Row Document Table

Agenda

What is Elasticsearch SQL?1

Functions and Aggregations3

Geographic queries4

Text operators and relevancy2

Page 11: Elasticsearch SQL Webinar · 2020-06-07 · Elasticsearch SQL <> RDBMS Terminological Differences Relational Databases (RDBMS) Elasticsearch SQL Column Field Row Document Table

Aggregate Functions Scalar FunctionsMetric Aggregations: COUNT, SUM, MAX, AVG... Math: ABS, SQRT, LOG, COS, SIN, ACOS, ASIN….

GROUPING (except GROUP BY): HISTOGRAM String: RIGHT,LEFT,SUBSTRING,LENGTH, UCASE...

Conversion: CAST,CONVERT

Date: DAY, MONTH, YEAR, NOW, MONTH_NAME...

Conditional: IIF, ISNULL, CASE, NULLIF, GREATEST... Geo: ST_AsWKT, ST_WKTToSQL, ST_X, ST_Y, ST_Z, ST_Distance...

Functions and AggregationsTypes of Functions in Elasticsearch SQL

Page 12: Elasticsearch SQL Webinar · 2020-06-07 · Elasticsearch SQL <> RDBMS Terminological Differences Relational Databases (RDBMS) Elasticsearch SQL Column Field Row Document Table

Functions and AggregationsGroup By & Having

SELECT column_name, aggregate_function(column_name)

FROM ...

WHERE ...

GROUP BY column_name

HAVING aggregate_function(column_name) operator value;

Page 13: Elasticsearch SQL Webinar · 2020-06-07 · Elasticsearch SQL <> RDBMS Terminological Differences Relational Databases (RDBMS) Elasticsearch SQL Column Field Row Document Table

Functions and AggregationsGroup By & Having

SELECT column_name, aggregate_function(column_name)

FROM ...

WHERE ...

GROUP BY column_name

HAVING aggregate_function(column_name) operator value;

Bucket Agg

Pipeline Agg

Metric Agg

Page 14: Elasticsearch SQL Webinar · 2020-06-07 · Elasticsearch SQL <> RDBMS Terminological Differences Relational Databases (RDBMS) Elasticsearch SQL Column Field Row Document Table

14

Demo

Page 15: Elasticsearch SQL Webinar · 2020-06-07 · Elasticsearch SQL <> RDBMS Terminological Differences Relational Databases (RDBMS) Elasticsearch SQL Column Field Row Document Table

Agenda

What is Elasticsearch SQL?1

Functions and Aggregations3

Geographic queries4

Text operators and relevancy2

Page 16: Elasticsearch SQL Webinar · 2020-06-07 · Elasticsearch SQL <> RDBMS Terminological Differences Relational Databases (RDBMS) Elasticsearch SQL Column Field Row Document Table

Geographic Queries

• Implements OpenGIS Simple Features Implementation Specification for SQL

• Currently supports ST_AsWKT, ST_WKTToSQL, ST_GeometryType, ST_X, ST_Y, ST_Z, ST_Distance

• Internally the Elasticsearch types supported are geo_point and geo_shape containing a point only

Standard GeoSQL Implementation on top of Elasticsearch

JDBC

ODBC

REST API

GeoSQL

Page 17: Elasticsearch SQL Webinar · 2020-06-07 · Elasticsearch SQL <> RDBMS Terminological Differences Relational Databases (RDBMS) Elasticsearch SQL Column Field Row Document Table

17

Demo

Page 18: Elasticsearch SQL Webinar · 2020-06-07 · Elasticsearch SQL <> RDBMS Terminological Differences Relational Databases (RDBMS) Elasticsearch SQL Column Field Row Document Table

18

Q & AThank you