Riak Search on "Sets" data-types

Alex De la rosa alex.rosa.box at gmail.com
Fri Aug 22 03:57:37 EDT 2014


Answering my own question, in case somebody has the same need some day,
seems that a SET works like a collection of REGISTERS and you can use it as
follows:

r = client.fulltext_search('ix_images', 'keywords_set:DLSR')

Thanks!
Alex

On Thu, Aug 21, 2014 at 8:32 PM, Alex De la rosa <alex.rosa.box at gmail.com>
wrote:

> Hi there,
>
> For a project I'm building I'm saving a "keyword" and a "site" for an
> image like this:
>
>   bucket = client.bucket_type('tp_images').bucket('images')
>   key = bucket.new(image_hash)
>   key.registers['raw'].assign(base64.b64encode(image_data))
>   key.registers['site'].assign('johnlewis.com')
>   key.registers['keywords'].assign('cameras')
>   key.store()
>
> and querying the index like this to get the desired images:
>
>   r = client.fulltext_search('ix_images', 'site_registers:johnlewis.com AND
> keywords_registers:cameras', sort='clicks_counter desc', rows=5)
>
> Imagine now that i want to associate the same image to different keywords,
> having a SET instead of a REGISTER:
>
>   bucket = client.bucket_type('tp_images').bucket('images')
>   key = bucket.new(image_hash)
>   key.registers['raw'].assign(base64.b64encode(image_data))
>   key.registers['site'].assign('johnlewis.com')
>   key.sets['keywords'].add('digital cameras')
>   key.sets['keywords'].add('DLSR')
>   key.store()
>
> How to query the SET using Riak Search? Something like the "IN ()"
> statement in traditional SQL:
>
>   r = client.fulltext_search('ix_images', 'site_registers:johnlewis.com AND
> keywords_set:???????', sort='clicks_counter desc', rows=5)
>
> Thanks!
> Alex
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.basho.com/pipermail/riak-users_lists.basho.com/attachments/20140822/9e76c9d5/attachment.html>


More information about the riak-users mailing list