redisjson-py
redisjson-py copied to clipboard
How to search in a list?
I see a key pointing to list of json :
redis_json_client.jsonset('customers', Path.rootPath(), { "customers": []})
example of insreted json customer_json:
{
"customer_status": "Active",
"first_name": "Leonard",
"last_name": "Cohen",
"customer_no": 1
}
So now I append each of the json as following:
redis_json_client.jsonarrappend('customers', Path('.customers'), customer_json)
I'd like to preform a search finding specific customer_no I tried something like:
customer_redis = redis_json_client.jsonget('customers', Path('customer_no'),370471789)
Q: 1.The reaosn for creating a list of json is that i'd like to some category collection in redis ,i wonder how bad it effect the performance , I could also assign the json as : key,customer_json instead of key,[customer_json]
2.How could i preform a search for specific json where key holds a list of json as desribe above?
- When searching in an it's O(n) where n is the length of the array, while when you use map it's O(1)
- To search for a specific JSON that hold a specific value you'll have to use RediSearch, we are going to release in the next few weeks this capability.
Meanwhile you can this preview docker redislabs/redisearch:feature-search-json
docker run -p 6379:6379 redislabs/redisearch:feature-search-json