Question

I'm trying to work with Riak on PHP. I read the documentation but no luck. So I've already configured the "search" option in /etc/init.d/app.conf as true. So, print_r($results) returns as null array.

# Connect to Riak
$client = new RiakClient('127.0.0.1', 8098);

$bucket = $client->bucket("searchbucket");
$bucket->newObject("one", array("foo"=>"one", "bar"=>"red"))->store();
$bucket->newObject("two", array("foo"=>"two", "bar"=>"green"))->store();

# Execute a search for all objects with matching properties
$results = $client->search("searchbucket", "foo:one OR foo:two")->run();


print_r($results);

What is wrong with my code? What I misunderstood?

Was it helpful?

Solution

In addition to enabling search in the app.config file, you also need to explicitly enable it for the buckets you want to be able to search. This can be done by adding a Riak Search commit hook to the bucket properties.

If you retrieve the bucket properties for 'searchbucket' you should be able to see a commit hook listed.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top