Tropical Software Observations

27 July 2010

Posted by Unknown

at 2:05 PM

2 comments

Labels: , ,

Spatial Search with Grails and Solr Plugin

Grails has a good Solr plugin (http://www.grails.org/plugin/solr) that works well and also provides spatial search that works out of the box. However, the documentation to use this feature is a bit skimpy so here are the basic steps to enable spatial search with Solr for your Grails app.

Install the solr plugin for Grails using 'grails install-plugin solr' and enable Solr indexing for your domain class by:

    static enableSolrSearch = true
    static solrAutoIndex = true

Next, we need to add a Solr index field annotation to the domain members.


    //import org.grails.solr.Solr
    @Solr(field="latitude_rad_d")
    Double latitude

    @Solr(field="longitude_rad_d")
    Double longitude


Once we have those in place, we can use SolrService to query:

    getSpatialQuery(query, lat, lng, range)

07 July 2010

Posted by Unknown

at 11:13 AM

0 comments

Labels: ,

Android: Twitter4j with xauth

The latest Twitter4j 2.1.3 supports xauth but it's not well documented at the moment. However it's really simple to use, check it out!



// Specify the consumer key and consumer secret 
// via system properties or configurationbuilder

System.setProperty("twitter4j.oauth.consumerKey",TWITTER_CONSUMER);
System.setProperty("twitter4j.oauth.consumerSecret",TWITTER_SECRET); 



// Then authenticate as normal
Twitter twitter = new TwitterFactory().getInstance(username,
password);



// Next the token will be available to you
AccessToken token = twitter.getOAuthAccessToken();


// You must store the access token and reuse this token
twitter.setOAuthAccessToken(token);