SlideShare a Scribd company logo
Indexing, Searching, and Aggregation in
Redis with RediSearch and .NET
Presented by: Steve Lorello - Developer Advocate @Redis
Twitter: @slorello
Agenda ● Introduction to Redis
● Redis Data Structures
● Secondary Indices
● Building Secondary Indices with any Redis
● Building Secondary Indices with RediSearch
● Writing Queries for Redis
● Writing Aggregations for Redis
What is Redis?
● NoSQL Database
● In-Memory Database
● Fundamentally a key-value
store
● Multimodal Database
● Fast
● Simple - Extremely Popular
Redis Data
Structures
● Strings
● Sets
● Sorted Sets
● Hashes
● JSON
Strings
● Single key retrieves single value
● Value can further be encoded as numeric/string
● Most basic Data Type in Redis
● Many users of Redis never look beyond this data type
SET foo bar
● Set of Redis Strings
● Unordered
● No duplication
● Set Operations
○ Intersection
○ Difference
○ Union
Person:Name:Steve = {Person:1}
Sets
SADD Person:Name:Steve Person:1
Sorted Set
● Ordered Sets
● Score Member
● No duplicate members
● Can be Ordered by
○ Score
○ Lexicographically.
Person:Age
Id Score
Person:1 32
Person:2 45
ZADD Person:Age 32 Person:1 45 Person:2
Redis Hashes
● Field Value Stores
● Flat Objects
● Field Names are Strings
● Field Values are strings
HSET Person:1 age 32 firstName Steve
Person:1
age 32
firstName Steve
Json
● Store objects as JSON
● Access via JSONPath
● Update via JSONPath
● Redis Module
● Source Available License
JSON.SET Person:1 .
‘{“firstName”:”Steve”,”age”:32}’
Finding Stuff In Redis
SELECT * FROM people
WHERE firstName = ‘Steve’
SELECT * FROM people
WHERE age < 35
You Can’t Just Search for things in Redis
Unless You Build a Secondary Index
Secondary Indices
● Efficiently find items in Primary Index
● Redis Primary Index = Keys
● Explicitly Declared
● Separate Maintenance and Updating
Source: https://lethain.com/global-secondary-indexes/
Secondary Indices in Redis Vanilla
● Exact Match Text - Unsorted -> Sets
● Exact Match Numeric - Unsorted -> Sets
● Numeric Sorted -> Sorted Sets
● Full Text -> Sorted Sets
Person:Name:Steve = {Person:1}
Person:Age
Id Score
Person:1 32
Person:2 45
Exact Match
● Store data in a Hash
● Foreach IndexName:Field:Value create a set
● Query the set for the IndexName:Field:Value then query hashes for
the result
● If you want to run more complicated queries, use set combination
operations to combine queries
Range Queries Numeric
● Use Sorted Sets store scores for particular fields
● Use Range Queries
Cons
● This can be done on any
Redis Database
● Total control over what you
index and what you don’t
● Excellent for Job Security
● Complicated to do any sort of
complex data modeling
● Impossible to horizontally
scale database and maintain
atomicity when updating data
● Needs regular consistency
updating throughout cluster.
Pros
OSS Redis Indexing Pros and Cons
RediSearch
What is RediSearch
● Module of Redis maintained by Redis
● Allows you to define schema of index
● Redis will take care of indexing
● Automatically index your data
● Provides Full Text Search Capabilities
● Provides Geo Filtering Capabilities
● Index automatically maintained cross-shards
● Source Available License
Spin up RediSearch
docker run -p 6379:6379 redislabs/redisearch
Creating Indices
● Indices are declared on types (Hash or JSON)
● Indices may be declared on Prefixes (e.g. Person:)
● Indices contain a schema mapping fields -> index types
● 4 index types
○ Tag (exact match or faceted matches)
○ Text (Full Text Search)
○ Numeric
○ Geo
Querying
● FT.SEARCH
● Query Syntax varies by data type
○ Tag -> @FieldName:{search Data}
○ Text -> @FieldName:search Data
○ Geo -> GEOFILTER @fieldName lon lat radius unit
○ Numeric -> @FieldName:[lowerBound upperBound]
Aggregations
● Query Data along same syntax as standard querying
● Build Pipelines to Transform indexed data in Redis
● Group like items together and run reductions on them
● Filter Data based off results of aggregations
Apply Functions
● Apply functions to your data
○ E.g. “@sales * @sales_regional_adjustment” AS SALES_ADJUSTED
● Use a variety of mathematical, string and timestamp functions
● Store results of apply functions in the pipeline, and use them later for
reductions and further apply functions
GroupBy and Reductions
● Records with like fields can be grouped together
● Grouped records can run reduction functions to combine them
○ E.g. SUM, AVERAGE, Stand Deviation etc. .
● Grouped records can be returned or passed further down the pipeline
● Declarative syntax for Index Creation
● Fluent API for Searching and Aggregation
● Object Mapping for mapping objects to Redis Data
Structures
Steve Lorello
Developer Advocate
@Redis
@slorello
github.com/slorello89
slorello.com
Resources
Redis
https://redis.io
RediSearch
https://redisearch.io
Redis Search Docker Image
https://hub.docker.com/r/redislabs/redisearch/
Redis OM
https://github.com/redis/redis-om-dotnet
Come Check Us Out!
Redis University:
https://university.redis.com
Discord:
https://discord.com/invite/redis

More Related Content

What's hot

Files Vs DataBase
Files Vs DataBaseFiles Vs DataBase
Files Vs DataBase
Dr. C.V. Suresh Babu
 
SQL for interview
SQL for interviewSQL for interview
SQL for interview
Aditya Kumar Tripathy
 
DBMS 2 | Entity Relationship Model
DBMS 2 | Entity Relationship ModelDBMS 2 | Entity Relationship Model
DBMS 2 | Entity Relationship Model
Mohammad Imam Hossain
 
Database fundamentals(database)
Database fundamentals(database)Database fundamentals(database)
Database fundamentals(database)
welcometofacebook
 
Database Relationships
Database RelationshipsDatabase Relationships
Database Relationships
wmassie
 
old file system/traditional file sysytem
old file system/traditional file sysytemold file system/traditional file sysytem
old file system/traditional file sysytem
jizaka
 
DDL And DML
DDL And DMLDDL And DML
DDL And DML
pnp @in
 
Introduction: Databases and Database Users
Introduction: Databases and Database UsersIntroduction: Databases and Database Users
Introduction: Databases and Database Users
sontumax
 
Data Job Salaries.pptx
Data Job Salaries.pptxData Job Salaries.pptx
Data Job Salaries.pptx
Nat O
 
DBMS unit-5.pdf
DBMS unit-5.pdfDBMS unit-5.pdf
DBMS unit-5.pdf
Prof. Dr. K. Adisesha
 
What is a DATA DICTIONARY?
What is a DATA DICTIONARY?What is a DATA DICTIONARY?
What is a DATA DICTIONARY?
Leela Vasundara D K
 
Bi validator Tableau Setup
Bi validator   Tableau SetupBi validator   Tableau Setup
Bi validator Tableau Setup
Datagaps Inc
 
SQL Basics
SQL BasicsSQL Basics
SQL Basics
Hammad Rasheed
 
MySql slides (ppt)
MySql slides (ppt)MySql slides (ppt)
MySql slides (ppt)
webhostingguy
 
Nonrelational Databases
Nonrelational DatabasesNonrelational Databases
Nonrelational Databases
Udi Bauman
 
2022-Db2-Securing_Your_data_in_motion.pdf
2022-Db2-Securing_Your_data_in_motion.pdf2022-Db2-Securing_Your_data_in_motion.pdf
2022-Db2-Securing_Your_data_in_motion.pdf
Roland Schock
 
Data recovery
Data recoveryData recovery
Data recovery
Nithin Sathees
 
Unit 01 dbms
Unit 01 dbmsUnit 01 dbms
Unit 01 dbms
anuragmbst
 
SQL
SQLSQL
Database Health Check
Database Health CheckDatabase Health Check
Database Health Check
PostgreSQL Experts, Inc.
 

What's hot (20)

Files Vs DataBase
Files Vs DataBaseFiles Vs DataBase
Files Vs DataBase
 
SQL for interview
SQL for interviewSQL for interview
SQL for interview
 
DBMS 2 | Entity Relationship Model
DBMS 2 | Entity Relationship ModelDBMS 2 | Entity Relationship Model
DBMS 2 | Entity Relationship Model
 
Database fundamentals(database)
Database fundamentals(database)Database fundamentals(database)
Database fundamentals(database)
 
Database Relationships
Database RelationshipsDatabase Relationships
Database Relationships
 
old file system/traditional file sysytem
old file system/traditional file sysytemold file system/traditional file sysytem
old file system/traditional file sysytem
 
DDL And DML
DDL And DMLDDL And DML
DDL And DML
 
Introduction: Databases and Database Users
Introduction: Databases and Database UsersIntroduction: Databases and Database Users
Introduction: Databases and Database Users
 
Data Job Salaries.pptx
Data Job Salaries.pptxData Job Salaries.pptx
Data Job Salaries.pptx
 
DBMS unit-5.pdf
DBMS unit-5.pdfDBMS unit-5.pdf
DBMS unit-5.pdf
 
What is a DATA DICTIONARY?
What is a DATA DICTIONARY?What is a DATA DICTIONARY?
What is a DATA DICTIONARY?
 
Bi validator Tableau Setup
Bi validator   Tableau SetupBi validator   Tableau Setup
Bi validator Tableau Setup
 
SQL Basics
SQL BasicsSQL Basics
SQL Basics
 
MySql slides (ppt)
MySql slides (ppt)MySql slides (ppt)
MySql slides (ppt)
 
Nonrelational Databases
Nonrelational DatabasesNonrelational Databases
Nonrelational Databases
 
2022-Db2-Securing_Your_data_in_motion.pdf
2022-Db2-Securing_Your_data_in_motion.pdf2022-Db2-Securing_Your_data_in_motion.pdf
2022-Db2-Securing_Your_data_in_motion.pdf
 
Data recovery
Data recoveryData recovery
Data recovery
 
Unit 01 dbms
Unit 01 dbmsUnit 01 dbms
Unit 01 dbms
 
SQL
SQLSQL
SQL
 
Database Health Check
Database Health CheckDatabase Health Check
Database Health Check
 

Similar to Indexing, searching, and aggregation with redi search and .net

PostgreSQL - Object Relational Database
PostgreSQL - Object Relational DatabasePostgreSQL - Object Relational Database
PostgreSQL - Object Relational Database
Mubashar Iqbal
 
Introducing Datawave
Introducing DatawaveIntroducing Datawave
Introducing Datawave
Accumulo Summit
 
MySQL Indexing
MySQL IndexingMySQL Indexing
MySQL Indexing
BADR
 
Redis - Your Magical superfast database
Redis - Your Magical superfast databaseRedis - Your Magical superfast database
Redis - Your Magical superfast database
the100rabh
 
An Introduction to Redis for .NET Developers.pdf
An Introduction to Redis for .NET Developers.pdfAn Introduction to Redis for .NET Developers.pdf
An Introduction to Redis for .NET Developers.pdf
Stephen Lorello
 
NoSQL document oriented data access for .net systems with postgresql and marten
NoSQL document oriented data access for .net systems with postgresql and martenNoSQL document oriented data access for .net systems with postgresql and marten
NoSQL document oriented data access for .net systems with postgresql and marten
Bojan Veljanovski
 
Pandas
PandasPandas
Introduction to Redis Data Structures: Sorted Sets
Introduction to Redis Data Structures: Sorted SetsIntroduction to Redis Data Structures: Sorted Sets
Introduction to Redis Data Structures: Sorted Sets
ScaleGrid.io
 
An Introduction to Redis for Developers.pdf
An Introduction to Redis for Developers.pdfAn Introduction to Redis for Developers.pdf
An Introduction to Redis for Developers.pdf
Stephen Lorello
 
No sql bigdata and postgresql
No sql bigdata and postgresqlNo sql bigdata and postgresql
No sql bigdata and postgresql
Zaid Shabbir
 
Mongodb Performance
Mongodb PerformanceMongodb Performance
Mongodb Performance
Jack
 
Steam Learn: Introduction to RDBMS indexes
Steam Learn: Introduction to RDBMS indexesSteam Learn: Introduction to RDBMS indexes
Steam Learn: Introduction to RDBMS indexes
inovia
 
DynamodbDB Deep Dive
DynamodbDB Deep DiveDynamodbDB Deep Dive
DynamodbDB Deep Dive
Amazon Web Services
 
SQL or NoSQL - how to choose
SQL or NoSQL - how to chooseSQL or NoSQL - how to choose
SQL or NoSQL - how to choose
Lars Thorup
 
Neo4j graph database
Neo4j graph databaseNeo4j graph database
Neo4j graph database
Prashant Bhargava
 
Google app engine - Soft Uni 19.06.2014
Google app engine - Soft Uni 19.06.2014Google app engine - Soft Uni 19.06.2014
Google app engine - Soft Uni 19.06.2014
Dimitar Danailov
 
Neo4j: Graph-like power
Neo4j: Graph-like powerNeo4j: Graph-like power
Neo4j: Graph-like power
Roman Rodomansky
 
Nosql part 2
Nosql part 2Nosql part 2
Nosql part 2
Ruru Chowdhury
 
Discovering python search engine
Discovering python search engineDiscovering python search engine
Discovering python search engine
Jose Manuel Ortega Candel
 
Architecting Database by Jony Sugianto (Detik.com)
Architecting Database by Jony Sugianto (Detik.com)Architecting Database by Jony Sugianto (Detik.com)
Architecting Database by Jony Sugianto (Detik.com)
Tech in Asia ID
 

Similar to Indexing, searching, and aggregation with redi search and .net (20)

PostgreSQL - Object Relational Database
PostgreSQL - Object Relational DatabasePostgreSQL - Object Relational Database
PostgreSQL - Object Relational Database
 
Introducing Datawave
Introducing DatawaveIntroducing Datawave
Introducing Datawave
 
MySQL Indexing
MySQL IndexingMySQL Indexing
MySQL Indexing
 
Redis - Your Magical superfast database
Redis - Your Magical superfast databaseRedis - Your Magical superfast database
Redis - Your Magical superfast database
 
An Introduction to Redis for .NET Developers.pdf
An Introduction to Redis for .NET Developers.pdfAn Introduction to Redis for .NET Developers.pdf
An Introduction to Redis for .NET Developers.pdf
 
NoSQL document oriented data access for .net systems with postgresql and marten
NoSQL document oriented data access for .net systems with postgresql and martenNoSQL document oriented data access for .net systems with postgresql and marten
NoSQL document oriented data access for .net systems with postgresql and marten
 
Pandas
PandasPandas
Pandas
 
Introduction to Redis Data Structures: Sorted Sets
Introduction to Redis Data Structures: Sorted SetsIntroduction to Redis Data Structures: Sorted Sets
Introduction to Redis Data Structures: Sorted Sets
 
An Introduction to Redis for Developers.pdf
An Introduction to Redis for Developers.pdfAn Introduction to Redis for Developers.pdf
An Introduction to Redis for Developers.pdf
 
No sql bigdata and postgresql
No sql bigdata and postgresqlNo sql bigdata and postgresql
No sql bigdata and postgresql
 
Mongodb Performance
Mongodb PerformanceMongodb Performance
Mongodb Performance
 
Steam Learn: Introduction to RDBMS indexes
Steam Learn: Introduction to RDBMS indexesSteam Learn: Introduction to RDBMS indexes
Steam Learn: Introduction to RDBMS indexes
 
DynamodbDB Deep Dive
DynamodbDB Deep DiveDynamodbDB Deep Dive
DynamodbDB Deep Dive
 
SQL or NoSQL - how to choose
SQL or NoSQL - how to chooseSQL or NoSQL - how to choose
SQL or NoSQL - how to choose
 
Neo4j graph database
Neo4j graph databaseNeo4j graph database
Neo4j graph database
 
Google app engine - Soft Uni 19.06.2014
Google app engine - Soft Uni 19.06.2014Google app engine - Soft Uni 19.06.2014
Google app engine - Soft Uni 19.06.2014
 
Neo4j: Graph-like power
Neo4j: Graph-like powerNeo4j: Graph-like power
Neo4j: Graph-like power
 
Nosql part 2
Nosql part 2Nosql part 2
Nosql part 2
 
Discovering python search engine
Discovering python search engineDiscovering python search engine
Discovering python search engine
 
Architecting Database by Jony Sugianto (Detik.com)
Architecting Database by Jony Sugianto (Detik.com)Architecting Database by Jony Sugianto (Detik.com)
Architecting Database by Jony Sugianto (Detik.com)
 

Recently uploaded

Measures in SQL (SIGMOD 2024, Santiago, Chile)
Measures in SQL (SIGMOD 2024, Santiago, Chile)Measures in SQL (SIGMOD 2024, Santiago, Chile)
Measures in SQL (SIGMOD 2024, Santiago, Chile)
Julian Hyde
 
E-commerce Application Development Company.pdf
E-commerce Application Development Company.pdfE-commerce Application Development Company.pdf
E-commerce Application Development Company.pdf
Hornet Dynamics
 
Energy consumption of Database Management - Florina Jonuzi
Energy consumption of Database Management - Florina JonuziEnergy consumption of Database Management - Florina Jonuzi
Energy consumption of Database Management - Florina Jonuzi
Green Software Development
 
Automated software refactoring with OpenRewrite and Generative AI.pptx.pdf
Automated software refactoring with OpenRewrite and Generative AI.pptx.pdfAutomated software refactoring with OpenRewrite and Generative AI.pptx.pdf
Automated software refactoring with OpenRewrite and Generative AI.pptx.pdf
timtebeek1
 
Vitthal Shirke Java Microservices Resume.pdf
Vitthal Shirke Java Microservices Resume.pdfVitthal Shirke Java Microservices Resume.pdf
Vitthal Shirke Java Microservices Resume.pdf
Vitthal Shirke
 
LORRAINE ANDREI_LEQUIGAN_HOW TO USE WHATSAPP.pptx
LORRAINE ANDREI_LEQUIGAN_HOW TO USE WHATSAPP.pptxLORRAINE ANDREI_LEQUIGAN_HOW TO USE WHATSAPP.pptx
LORRAINE ANDREI_LEQUIGAN_HOW TO USE WHATSAPP.pptx
lorraineandreiamcidl
 
GraphSummit Paris - The art of the possible with Graph Technology
GraphSummit Paris - The art of the possible with Graph TechnologyGraphSummit Paris - The art of the possible with Graph Technology
GraphSummit Paris - The art of the possible with Graph Technology
Neo4j
 
Neo4j - Product Vision and Knowledge Graphs - GraphSummit Paris
Neo4j - Product Vision and Knowledge Graphs - GraphSummit ParisNeo4j - Product Vision and Knowledge Graphs - GraphSummit Paris
Neo4j - Product Vision and Knowledge Graphs - GraphSummit Paris
Neo4j
 
How to write a program in any programming language
How to write a program in any programming languageHow to write a program in any programming language
How to write a program in any programming language
Rakesh Kumar R
 
Transform Your Communication with Cloud-Based IVR Solutions
Transform Your Communication with Cloud-Based IVR SolutionsTransform Your Communication with Cloud-Based IVR Solutions
Transform Your Communication with Cloud-Based IVR Solutions
TheSMSPoint
 
LORRAINE ANDREI_LEQUIGAN_HOW TO USE ZOOM
LORRAINE ANDREI_LEQUIGAN_HOW TO USE ZOOMLORRAINE ANDREI_LEQUIGAN_HOW TO USE ZOOM
LORRAINE ANDREI_LEQUIGAN_HOW TO USE ZOOM
lorraineandreiamcidl
 
SMS API Integration in Saudi Arabia| Best SMS API Service
SMS API Integration in Saudi Arabia| Best SMS API ServiceSMS API Integration in Saudi Arabia| Best SMS API Service
SMS API Integration in Saudi Arabia| Best SMS API Service
Yara Milbes
 
8 Best Automated Android App Testing Tool and Framework in 2024.pdf
8 Best Automated Android App Testing Tool and Framework in 2024.pdf8 Best Automated Android App Testing Tool and Framework in 2024.pdf
8 Best Automated Android App Testing Tool and Framework in 2024.pdf
kalichargn70th171
 
Revolutionizing Visual Effects Mastering AI Face Swaps.pdf
Revolutionizing Visual Effects Mastering AI Face Swaps.pdfRevolutionizing Visual Effects Mastering AI Face Swaps.pdf
Revolutionizing Visual Effects Mastering AI Face Swaps.pdf
Undress Baby
 
Graspan: A Big Data System for Big Code Analysis
Graspan: A Big Data System for Big Code AnalysisGraspan: A Big Data System for Big Code Analysis
Graspan: A Big Data System for Big Code Analysis
Aftab Hussain
 
E-commerce Development Services- Hornet Dynamics
E-commerce Development Services- Hornet DynamicsE-commerce Development Services- Hornet Dynamics
E-commerce Development Services- Hornet Dynamics
Hornet Dynamics
 
socradar-q1-2024-aviation-industry-report.pdf
socradar-q1-2024-aviation-industry-report.pdfsocradar-q1-2024-aviation-industry-report.pdf
socradar-q1-2024-aviation-industry-report.pdf
SOCRadar
 
UI5con 2024 - Boost Your Development Experience with UI5 Tooling Extensions
UI5con 2024 - Boost Your Development Experience with UI5 Tooling ExtensionsUI5con 2024 - Boost Your Development Experience with UI5 Tooling Extensions
UI5con 2024 - Boost Your Development Experience with UI5 Tooling Extensions
Peter Muessig
 
Fundamentals of Programming and Language Processors
Fundamentals of Programming and Language ProcessorsFundamentals of Programming and Language Processors
Fundamentals of Programming and Language Processors
Rakesh Kumar R
 
KuberTENes Birthday Bash Guadalajara - Introducción a Argo CD
KuberTENes Birthday Bash Guadalajara - Introducción a Argo CDKuberTENes Birthday Bash Guadalajara - Introducción a Argo CD
KuberTENes Birthday Bash Guadalajara - Introducción a Argo CD
rodomar2
 

Recently uploaded (20)

Measures in SQL (SIGMOD 2024, Santiago, Chile)
Measures in SQL (SIGMOD 2024, Santiago, Chile)Measures in SQL (SIGMOD 2024, Santiago, Chile)
Measures in SQL (SIGMOD 2024, Santiago, Chile)
 
E-commerce Application Development Company.pdf
E-commerce Application Development Company.pdfE-commerce Application Development Company.pdf
E-commerce Application Development Company.pdf
 
Energy consumption of Database Management - Florina Jonuzi
Energy consumption of Database Management - Florina JonuziEnergy consumption of Database Management - Florina Jonuzi
Energy consumption of Database Management - Florina Jonuzi
 
Automated software refactoring with OpenRewrite and Generative AI.pptx.pdf
Automated software refactoring with OpenRewrite and Generative AI.pptx.pdfAutomated software refactoring with OpenRewrite and Generative AI.pptx.pdf
Automated software refactoring with OpenRewrite and Generative AI.pptx.pdf
 
Vitthal Shirke Java Microservices Resume.pdf
Vitthal Shirke Java Microservices Resume.pdfVitthal Shirke Java Microservices Resume.pdf
Vitthal Shirke Java Microservices Resume.pdf
 
LORRAINE ANDREI_LEQUIGAN_HOW TO USE WHATSAPP.pptx
LORRAINE ANDREI_LEQUIGAN_HOW TO USE WHATSAPP.pptxLORRAINE ANDREI_LEQUIGAN_HOW TO USE WHATSAPP.pptx
LORRAINE ANDREI_LEQUIGAN_HOW TO USE WHATSAPP.pptx
 
GraphSummit Paris - The art of the possible with Graph Technology
GraphSummit Paris - The art of the possible with Graph TechnologyGraphSummit Paris - The art of the possible with Graph Technology
GraphSummit Paris - The art of the possible with Graph Technology
 
Neo4j - Product Vision and Knowledge Graphs - GraphSummit Paris
Neo4j - Product Vision and Knowledge Graphs - GraphSummit ParisNeo4j - Product Vision and Knowledge Graphs - GraphSummit Paris
Neo4j - Product Vision and Knowledge Graphs - GraphSummit Paris
 
How to write a program in any programming language
How to write a program in any programming languageHow to write a program in any programming language
How to write a program in any programming language
 
Transform Your Communication with Cloud-Based IVR Solutions
Transform Your Communication with Cloud-Based IVR SolutionsTransform Your Communication with Cloud-Based IVR Solutions
Transform Your Communication with Cloud-Based IVR Solutions
 
LORRAINE ANDREI_LEQUIGAN_HOW TO USE ZOOM
LORRAINE ANDREI_LEQUIGAN_HOW TO USE ZOOMLORRAINE ANDREI_LEQUIGAN_HOW TO USE ZOOM
LORRAINE ANDREI_LEQUIGAN_HOW TO USE ZOOM
 
SMS API Integration in Saudi Arabia| Best SMS API Service
SMS API Integration in Saudi Arabia| Best SMS API ServiceSMS API Integration in Saudi Arabia| Best SMS API Service
SMS API Integration in Saudi Arabia| Best SMS API Service
 
8 Best Automated Android App Testing Tool and Framework in 2024.pdf
8 Best Automated Android App Testing Tool and Framework in 2024.pdf8 Best Automated Android App Testing Tool and Framework in 2024.pdf
8 Best Automated Android App Testing Tool and Framework in 2024.pdf
 
Revolutionizing Visual Effects Mastering AI Face Swaps.pdf
Revolutionizing Visual Effects Mastering AI Face Swaps.pdfRevolutionizing Visual Effects Mastering AI Face Swaps.pdf
Revolutionizing Visual Effects Mastering AI Face Swaps.pdf
 
Graspan: A Big Data System for Big Code Analysis
Graspan: A Big Data System for Big Code AnalysisGraspan: A Big Data System for Big Code Analysis
Graspan: A Big Data System for Big Code Analysis
 
E-commerce Development Services- Hornet Dynamics
E-commerce Development Services- Hornet DynamicsE-commerce Development Services- Hornet Dynamics
E-commerce Development Services- Hornet Dynamics
 
socradar-q1-2024-aviation-industry-report.pdf
socradar-q1-2024-aviation-industry-report.pdfsocradar-q1-2024-aviation-industry-report.pdf
socradar-q1-2024-aviation-industry-report.pdf
 
UI5con 2024 - Boost Your Development Experience with UI5 Tooling Extensions
UI5con 2024 - Boost Your Development Experience with UI5 Tooling ExtensionsUI5con 2024 - Boost Your Development Experience with UI5 Tooling Extensions
UI5con 2024 - Boost Your Development Experience with UI5 Tooling Extensions
 
Fundamentals of Programming and Language Processors
Fundamentals of Programming and Language ProcessorsFundamentals of Programming and Language Processors
Fundamentals of Programming and Language Processors
 
KuberTENes Birthday Bash Guadalajara - Introducción a Argo CD
KuberTENes Birthday Bash Guadalajara - Introducción a Argo CDKuberTENes Birthday Bash Guadalajara - Introducción a Argo CD
KuberTENes Birthday Bash Guadalajara - Introducción a Argo CD
 

Indexing, searching, and aggregation with redi search and .net

  • 1. Indexing, Searching, and Aggregation in Redis with RediSearch and .NET Presented by: Steve Lorello - Developer Advocate @Redis Twitter: @slorello
  • 2. Agenda ● Introduction to Redis ● Redis Data Structures ● Secondary Indices ● Building Secondary Indices with any Redis ● Building Secondary Indices with RediSearch ● Writing Queries for Redis ● Writing Aggregations for Redis
  • 3. What is Redis? ● NoSQL Database ● In-Memory Database ● Fundamentally a key-value store ● Multimodal Database ● Fast ● Simple - Extremely Popular
  • 4. Redis Data Structures ● Strings ● Sets ● Sorted Sets ● Hashes ● JSON
  • 5. Strings ● Single key retrieves single value ● Value can further be encoded as numeric/string ● Most basic Data Type in Redis ● Many users of Redis never look beyond this data type SET foo bar
  • 6. ● Set of Redis Strings ● Unordered ● No duplication ● Set Operations ○ Intersection ○ Difference ○ Union Person:Name:Steve = {Person:1} Sets SADD Person:Name:Steve Person:1
  • 7. Sorted Set ● Ordered Sets ● Score Member ● No duplicate members ● Can be Ordered by ○ Score ○ Lexicographically. Person:Age Id Score Person:1 32 Person:2 45 ZADD Person:Age 32 Person:1 45 Person:2
  • 8. Redis Hashes ● Field Value Stores ● Flat Objects ● Field Names are Strings ● Field Values are strings HSET Person:1 age 32 firstName Steve Person:1 age 32 firstName Steve
  • 9. Json ● Store objects as JSON ● Access via JSONPath ● Update via JSONPath ● Redis Module ● Source Available License JSON.SET Person:1 . ‘{“firstName”:”Steve”,”age”:32}’
  • 11. SELECT * FROM people WHERE firstName = ‘Steve’ SELECT * FROM people WHERE age < 35 You Can’t Just Search for things in Redis Unless You Build a Secondary Index
  • 12. Secondary Indices ● Efficiently find items in Primary Index ● Redis Primary Index = Keys ● Explicitly Declared ● Separate Maintenance and Updating Source: https://lethain.com/global-secondary-indexes/
  • 13. Secondary Indices in Redis Vanilla ● Exact Match Text - Unsorted -> Sets ● Exact Match Numeric - Unsorted -> Sets ● Numeric Sorted -> Sorted Sets ● Full Text -> Sorted Sets Person:Name:Steve = {Person:1} Person:Age Id Score Person:1 32 Person:2 45
  • 14. Exact Match ● Store data in a Hash ● Foreach IndexName:Field:Value create a set ● Query the set for the IndexName:Field:Value then query hashes for the result ● If you want to run more complicated queries, use set combination operations to combine queries
  • 15. Range Queries Numeric ● Use Sorted Sets store scores for particular fields ● Use Range Queries
  • 16. Cons ● This can be done on any Redis Database ● Total control over what you index and what you don’t ● Excellent for Job Security ● Complicated to do any sort of complex data modeling ● Impossible to horizontally scale database and maintain atomicity when updating data ● Needs regular consistency updating throughout cluster. Pros OSS Redis Indexing Pros and Cons
  • 18. What is RediSearch ● Module of Redis maintained by Redis ● Allows you to define schema of index ● Redis will take care of indexing ● Automatically index your data ● Provides Full Text Search Capabilities ● Provides Geo Filtering Capabilities ● Index automatically maintained cross-shards ● Source Available License
  • 19. Spin up RediSearch docker run -p 6379:6379 redislabs/redisearch
  • 20. Creating Indices ● Indices are declared on types (Hash or JSON) ● Indices may be declared on Prefixes (e.g. Person:) ● Indices contain a schema mapping fields -> index types ● 4 index types ○ Tag (exact match or faceted matches) ○ Text (Full Text Search) ○ Numeric ○ Geo
  • 21. Querying ● FT.SEARCH ● Query Syntax varies by data type ○ Tag -> @FieldName:{search Data} ○ Text -> @FieldName:search Data ○ Geo -> GEOFILTER @fieldName lon lat radius unit ○ Numeric -> @FieldName:[lowerBound upperBound]
  • 22. Aggregations ● Query Data along same syntax as standard querying ● Build Pipelines to Transform indexed data in Redis ● Group like items together and run reductions on them ● Filter Data based off results of aggregations
  • 23. Apply Functions ● Apply functions to your data ○ E.g. “@sales * @sales_regional_adjustment” AS SALES_ADJUSTED ● Use a variety of mathematical, string and timestamp functions ● Store results of apply functions in the pipeline, and use them later for reductions and further apply functions
  • 24. GroupBy and Reductions ● Records with like fields can be grouped together ● Grouped records can run reduction functions to combine them ○ E.g. SUM, AVERAGE, Stand Deviation etc. . ● Grouped records can be returned or passed further down the pipeline
  • 25. ● Declarative syntax for Index Creation ● Fluent API for Searching and Aggregation ● Object Mapping for mapping objects to Redis Data Structures
  • 27. Resources Redis https://redis.io RediSearch https://redisearch.io Redis Search Docker Image https://hub.docker.com/r/redislabs/redisearch/ Redis OM https://github.com/redis/redis-om-dotnet
  • 28. Come Check Us Out! Redis University: https://university.redis.com Discord: https://discord.com/invite/redis