Getting SolrJ to work on Google App Engine

For the past couple of months I've been working on a GAE project with search integration provided by Lucene Solr. I have Solr hosted on a VPS since Solr is not supported on GAE out-of-the-box as at the time of writing. To connect to a running Solr Server, you will need a client connector. I'm using the bundled SolrJ client connector to search Solr as well as performing data indexing. There are series of discussions on the internet talking about getting SolrJ to work to Google App Engine. I needed this to work as well. So I picked up the patch contributed by Noble Paul. The patch didn't work as expected due to a few gotchas. After a few hours, I got this to work for me. I have forked the core lucene-solr on github and placed this patch in there. So for anyone who might need it, here it is:


... // code ommitted for brevity
// Using SolrJ to make the request to Solr
            String url = "http://localhost:8983/solr";
            try {
                // Connect to Solr Server
                SolrServer server = new SimpleHttpSolrServer(url);
                log.log(Level.INFO, "Solr is connected: ");
                SolrQuery solrQuery = new SolrQuery(search.getText());
                log.log(Level.INFO, "Solr Query is executed: ");
                QueryResponse response = server.query(solrQuery);
                // log the response
                log.log(Level.INFO, "Search result is: ", response.toString());
                System.out.println("System print. Response is: " + response.toString());
            } catch(SolrServerException sse) {
                Logger.getLogger(Dashboard.class.getName()).log(Level.SEVERE, null, sse);

Reference Links

Post new comment

The content of this field is kept private and will not be shown publicly.