4/19/2013

eclipse-scala-tools 0.0.4 released!

eclipse-scala-tools is an Eclipse plug-in for sbt.

This is a list of new features and changes in this version:

  • Use system proxy setting
  • SBT 0.12 Support (SBT 0.7 and 0.10 are removed)
  • Use sbteclipse to generate Eclipse project configuration files
  • Outline view

And I have a plan about new features in the future release:

  • Scala IDE 3.x and sbt 0.13 support
  • Select some major libraries at the project creation wizard
  • Multi project support
  • Wizard to import existing sbt project from out of workspace

I hope this plug-in helps you. Enjoy!

4/04/2013

solr-scala-client 0.0.7 is now available!

solr-scala-client is a simple Apache Solr client for Scala based on SolrJ.

The list of new features in 0.0.7:

  • Add build for Scala 2.10
  • Upgrade to SolrJ 4.2.0
  • Support search result highlighting

In this entry, I introduce search result highlighting which is a new feature in this release.

How to Highlight?

You can configure the query to return the highlighted content using QueryBuilder#highlight(). The highlighted field is required, but prefix and suffix is not required. They are optional(default is <em>...</em>).

The highlighted content is set as the "highlight" property to the Map or the case class.

val result = client.query("content: Scala")
  // NOTE: unique key field is required.
  .fields("id")
  // Specify the highlighted field, prefix and postfix (prefix and postfix is optional).
  .highlight("content", "", "")
  .getResultAsMap()

result.documents.foreach { doc: Product =>
  println("id: " + doc("id"))
  println(doc("highlight")) // highlighted content is set as the "highlight" property
}

In SolrJ, we have to map retrieved documents and highlighted contents using the unique key of the index schema. solr-scala-client expects that the unique key is "id".

If your schema has the different field as the unique key, you can specify the unique key name as following:

val result = client.query("content: Scala")
  .id("documentId") // Specify the unique key name
  .fields("documentId")
  .highlight("content", "", "")
  .getResultAsMap()