Last active
September 26, 2016 16:15
-
-
Save dvirsky/badf0967a2cbfae66255b2feca2742ed to your computer and use it in GitHub Desktop.
index example
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# creating an index: | |
127.0.0.1:6379> IDX.CREATE users TYPE HASH SCHEMA name STRING age INT32 | |
OK | |
# running HASH commands while indexing them: | |
127.0.0.1:6379> IDX.INTO users HMSET user1 name "alice" age 24 | |
OK | |
127.0.0.1:6379> IDX.INTO users HMSET user2 name "bob" age 19 | |
OK | |
# seleting from the index using native redis commands: | |
127.0.0.1:6379> IDX.FROM users WHERE "name = 'alice'" HMGET $ age | |
1) 1) "24" | |
127.0.0.1:6379> IDX.FROM users WHERE "name = 'alice' AND age < 24" HMGET $ age | |
(empty list or set) | |
127.0.0.1:6379> IDX.FROM users WHERE "name IN ('alice','bob') AND age < 24" HMGET $ age | |
1) 1) "19" | |
127.0.0.1:6379> IDX.FROM users WHERE "name IN ('alice','bob') AND age < 24" HMGET $ age name | |
1) 1) "19" | |
2) "bob" | |
127.0.0.1:6379> IDX.FROM users WHERE "name LIKE 'al%'" HGETALL $ | |
1) 1) "name" | |
2) "alice" | |
3) "age" | |
4) "24" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment