def SetAsIndex():#find all rows that match an ad hoc boolean query of fields, this is value_1234 ^ value_9876
res = execute('SINTER', 'value_1234', 'value_9876')
for x in res:
res2 = execute('HMGET', 'profile_'+x, 'value_1234', 'value_9876')
#python isn't my daily language so I'm sure there is a better way of writing this...
retDict = {'key':'profile_'+x}
valueDict = {}
valueDict['value_1234'] = res2[0]
valueDict['value_9876'] = res2[1]
retDict["value"] = valueDict
yield retDict
bg = GearsBuilder('PythonReader')
#uncomment for the full scan version
#bg = GearsBuilder();#bg.filter(lambda x: 'value_1234' in x['value'] and 'value_9876' in x['value'])
bg.groupby(lambda r : r['value']['value_1234'] + ',' + r['value']['value_9876'], lambda key,a,r: 1 + (a if a else 0))
#bg.run('profile_*')
bg.run(SetAsIndex)Disclaimer
The information contained in this communication from the sender is confidential. It is intended solely for use by the recipient and others authorized to receive it. If you are not the recipient, you are hereby notified that any disclosure, copying, distribution or taking action in relation of the contents of this information is strictly prohibited and may be unlawful.
This email has been scanned for viruses and malware, and may have been automatically archived by Mimecast Ltd, an innovator in Software as a Service (SaaS) for business. Providing a safer and more useful place for your human generated data. Specializing in; Security, archiving and compliance. To find out more Click Here.--
You received this message because you are subscribed to the Google Groups "RedisGears Discussion Forum" group.
To unsubscribe from this group and stop receiving emails from it, send an email to redisgears+...@googlegroups.com.
To view this discussion on the web, visit https://groups.google.com/d/msgid/redisgears/fa409b51-cd7f-48d2-acb2-5df06d2b8b94%40googlegroups.com.
To unsubscribe from this group and stop receiving emails from it, send an email to redis...@googlegroups.com.
To unsubscribe from this group and stop receiving emails from it, send an email to redisgears+...@googlegroups.com.
To view this discussion on the web, visit https://groups.google.com/d/msgid/redisgears/9d52b7ac-69e7-4b99-92a4-e16496e6ec23%40googlegroups.com.
def IndexHash(x): print(x) key = x['key'] val = x['value'] for k in val.keys(): execute('sadd', '%s{%s}' % (k, hashtag()), key)
GB().foreach(IndexHash).register(mode='sync', eventTypes=['hset', 'hmset'])127.0.0.1:6379> hset k foo bar bar foodef SetAsIndex(r): keys = ['%s{%s}' % (a, hashtag()) for a in r] res = execute('SINTER', *keys) final_res = [] for x in res: res2 = execute('HMGET', x, *r) retDict = {'key':x} valueDict = {} for i in range(len(r)): valueDict[r[i]] = res2[i] retDict["value"] = valueDict final_res.append(retDict) return final_res
bg = GearsBuilder('CommandReader')bg.map(lambda x: x[1:]) # the command reader first argument is the command and we do not need itbg.flatmap(SetAsIndex)bg.countby(lambda r : ','.join(r['value'].keys()))bg.register(trigger='intersect_search')127.0.0.1:6379> RG.TRIGGER intersect_search foo bar1) "{'key': 'foo,bar', 'value': 1}"To view this discussion on the web, visit https://groups.google.com/d/msgid/redisgears/9d52b7ac-69e7-4b99-92a4-e16496e6ec23%40googlegroups.com.
To unsubscribe from this group and stop receiving emails from it, send an email to redisgears+...@googlegroups.com.
To view this discussion on the web, visit https://groups.google.com/d/msgid/redisgears/88a58392-41ff-46db-8fc4-cbadff9dbecc%40googlegroups.com.
To view this discussion on the web, visit https://groups.google.com/d/msgid/redisgears/88a58392-41ff-46db-8fc4-cbadff9dbecc%40googlegroups.com.