Hi Carson, You are definitely on the right track. The SearchQuery parameter is a Lucene-syntax-ish search query, and the Bucket parameter is the bucket on which to search. You can find more information on the query syntax here: http://wiki.basho.com/display/RIAK/Riak+Search+-+Querying
Usage is as follows: {ok, Pid} = riakc_pb_socket:start("127.0.0.1", "8087"), Bucket = "json", SearchQuery = "firstname:John"), {ok, BucketKeyList} = riakc_pb_socket:search(Pid, Bucket, SearchQuery, riakc_pb_socket:stop(Pid). You can also do more complicated things like using the results to spawn a map/reduce operation by adding a MapReducePhases parameter. You can find more information on map/reduce phases here: http://wiki.basho.com/display/RIAK/MapReduce {ok, Result} = riakc_pb_socket:search(Pid, "json", "firstname:John", MapReducePhases, TimeoutInMS), Best, Rusty On Mon, Dec 13, 2010 at 4:33 PM, carson li <carson...@liquidanalytics.com>wrote: > hey everyone, > > i just started off with using riak search. (i have some basic riak > experience) and i don't know how to use the erlang api for riak to do search > queries. > > what i've done so far > ------------------------------ > I have successfully installed the KV hook, put in a json document, > and also used the search-cmd to retrieve something. for reference i put in > the json > > { > firstname:"John", > lastName:"Smith" > } > > with the command curl -X PUT http://127.0.0.1:8098/riak/test/123 -H > "Content-Type: application/json" -d @test.json > > to retrieve something i by navigating to riah search's bin, then > ./search-cmd search json firstname:John > > the above works well. > now i'm buildling an aplpication with webmachine / erlang. and i want to be > able to perform searches as well. > the wiki indicates that the Erlang api should support this > > https://wiki.basho.com/display/RIAK/Riak+Search+-+Querying > > looking at riakc_pb_socket.erl, i see there is a search method that has the > signature search(Pid, Bucket, SearchQuery) > > so what exactly is SearchQuery, how is it supposed to look like. So it > just gets passed into a mapred_search? > I'm confused on how this works. Can someone please provide a simple > example, of how i can search for say firstname:John with the json above? > > any help would be greatly appreciated. > > > > -- > Carson Li > Liquid Analytics > carson...@liquidanalytics.com > 647-273-1024 > > > _______________________________________________ > 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