Redis Search
Redis Search is a
A rich query language
Full-text search
Geospatial queries
Aggregations
For searching first you have to create INDEXES
FT.CREATE {index_name} ON JSON SCHEMA {json_path} AS {attribute} {type}
<indexName>
: The name of the index you are creating.[ON <structure>]
: Specifies the data structure to index, which can beHASH
(default) orJSON
if you're indexing JSON documents with RedisJSON.[PREFIX count <prefix> ...]
: Defines one or more key prefixes. Only keys that match the prefix(es) will be indexed.SCHEMA
: Followed by one or more field definitions.<field>
: The name of the field to index.<type>
: The type of the field (TEXT
,NUMERIC
,GEO
, orTAG
).
FT.CREATE idx:friends ON JSON PREFIX 1 "friends:character:" SCHEMA $.friends[*] AS friend TAG
FT.SEARCH idx:friends "@friend:{Joey Tribbiani}"
FT.CREATE idx:occupation ON JSON PREFIX 1 "friends:character:" SCHEMA $.occupation AS occupation TEXT
FT.SEARCH idx:occupation "*"
FT.SEARCH idx:occupation "Chef"
FT.INFO idx:occupation
Last updated