8/02/2013

Non-blocking API for Apache Solr

Today, we've released solr-scala-client 0.0.8!!

This release includes asynchronous and non-blocking API based on AsyncHttpClient and Scala 2.10's Future. See the following simple example:

val client = new AsyncSolrClient("http://localhost:8983/solr")

// Register
client
  .register(Map(
    "id"   -> "005", 
    "name" -> "ThinkPad X1 Carbon", 
    "manu" -> "Lenovo"))
  .onComplete{
    case Success(x) => println("registered!")
    case Failure(t) => t.printStackTrace()
  }

// Query
client.query("name:%name%")
  .fields("id", "manu", "name")
  .facetFields("manu")
  .sortBy("id", Order.asc)
  .getResultAsMap(Map("name" -> "ThinkPad X201s"))
  .onComplete {
    case Success(x) => println(x)
    case Failure(t) => t.printStackTrace()
  }

Methods of AsyncSolrClient return Future. You can process result by callback handler. See more example at here.

This release also contains some other new features such as recommendation search and automatic transaction management. Check the github site to know details of solr-scala-client!