Use case
Let's say you have a Riak bucket containing points of interests (bars, restaurants, movie theatres, ...) and you have already hacked Riak to allow your application to perform localized searches using HTTP (Solr-like) interface. Example : http://localhost:8098/riak/localsolr/points_of_interests/search?q="title:sushi"&lat=48.859871&lon=2.3633826
Solution
We need to use a custom Bucket class for the "points_of_interest" bucket. This class will add a "localSearch" method that will call a RiakSearchServiceClient with a modified mount point.
Detailled solution
We just add a new "points_of_interests" bucket with a custom Class
This class extends the base Bucket class and add a new localSearch method that depends on a custom RiakSearchServiceClient service. This service will be defined later on services.xml
This service listen to "riak.add.bucket" events and injects the riakLocalSearchServiceClient instance into each Bucket that are instance of AcmeBucket
LocalQuery is a superclass of Query and is used to perform local searches on bucket that supports them.
This configuration file describes :
- the route to query Riak Local Search mount point
- the localSearch service using the riak based search service
- the bucket builder and defines which event is listened and what method is called when this event is fired
A really basic example of how to use this hack.