Hi Mike,

You are missing the "run()" command at the end of client.search(). The
"search()" function creates a MapReduce object to which you can add map and
reduce phases. The "run()" command bundles up MapReduce job and sends it to
the Riak cluster for processing.

client.search('tweets', 'name:[andy TO john]').run() should give you the
results you are looking for.

If that still doesn't work, some sample code is below and more examples are
at
https://github.com/basho/riak-python-client/blob/master/riak/tests/test_all.py

Best,
Rusty

from riak import RiakClient
from riak import RiakHttpTransport

client = RiakClient("127.0.0.1", 8098)
bucket = client.bucket("tweets")

tweet = bucket.new('key1', data={ 'name': 'andy', 'text': 'text1' })
tweet.store()

tweet = bucket.new('key2', data={ 'name': 'bob', 'text': 'text2' })
tweet.store()

tweet = bucket.new('key3', data={ 'name': 'john', 'text': 'text3' })
tweet.store()

tweet = bucket.new('key4', data={ 'name': 'lloyd', 'text': 'text4' })
tweet.store()

results = client.search('tweets', 'name:[andy TO john]').run()
results[0].get().get_data()
results[1].get().get_data()
results[2].get().get_data()


On Fri, Feb 18, 2011 at 7:44 PM, Mike Stoddart <sto...@gmail.com> wrote:

> I'm experimenting with Riak Search; I'm storing tweets and then trying
> to query them. My code to store a tweet is:
>
>                       tweet = bucket.new(str(uuid.uuid1()), data={
>                               'name': s.user.name,
>                               'text': s.text,
>                       })
>                       tweet.store()
>
> My code to search the tweets is:
>
>    search_query = client.search('tweets', 'name:[andy TO john]')
>
> I've tried many different queries including:
>
>    search_query = client.search('tweets', 'text:and')
>
> But I never get any hits. Am I doing something fundamentally wrong? I
> print out the tweet as I add it to the database so I know what terms I
> can search on. But nothing works. I did remember to do:
>
> serach-cmd install tweets
>
> Any suggestions appreciated.
>
> Thanks
> Mike
>
> _______________________________________________
> riak-users mailing list
> riak-users@lists.basho.com
> http://lists.basho.com/mailman/listinfo/riak-users_lists.basho.com
>
_______________________________________________
riak-users mailing list
riak-users@lists.basho.com
http://lists.basho.com/mailman/listinfo/riak-users_lists.basho.com

Reply via email to