In Redis, you can model documents using:
Hashes:
- Best for representing rows in a relational database table
- Schemaless collections of flat field-value pairs
- Support CRUD operation on field-value pairs at any time, not just initial declaration
JSON:
- Best for representing documents in a document store
- Full support of the JSON format with nested objects and nested arrays
- Supports JSONPath -like syntax for selecting elements inside
- Supports atomic CRUD operations
Full-text search and querying is supported for both Hashes and JSON via a secondary index.
A number of data types are available for indexing:
- Full-text index with support of different languages, fuzzy, and phonetic
- Numeric range index
- Tag index supporting multiple values
- Geo index
- Vector index (upcoming)
Querying supports the following:
- Multiple fields queries
- Complex boolean queries with AND, OR, NOT operators between sub-queries
- Optional terms, fuzzy matching, prefix queries, clauses
- Projection of full document or just part of it
- Aggregations
What you will learn for both Hashes and JSON:
- CRUD operations
- Search and Querying
PRE-REQUISITES
Follow these instructions to set up the RedisJSON and RediSearch modules on Redis OSS.
For working with Hashes you will need Redis >=6, RediSearch >=2.0.
For working with JSON you will need Redis >=6, RediSearch >=2.2 and RedisJSON >=2.0.
You could also create a free and ready to use instance on Redis Cloud.