Over a million developers have joined DZone.
{{announcement.body}}
{{announcement.title}}

Behold! A Solr Client for Scala

DZone's Guide to

Behold! A Solr Client for Scala

· Java Zone
Free Resource

Try Okta to add social login, MFA, and OpenID Connect support to your Java app in minutes. Create a free developer account today and never build auth again.

Scala users, check this out!  If you've been trying to have a better interface for using Apache Solr in your Scala projects, there's a pretty new simple Solr client for Scala being developed on GitHub by Naoki Takezoe.  It hasn't been released yet but if this project is of interest to you, it might be worth it to lend a hand.

The client is based on SolrJ and you simply add a dependency into your build.sbt.  Here is the simplest example of its usage:
import jp.sf.amateras.solr.scala._

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

// register
client
  .add(Map("id"->"001", "manu" -> "Lenovo", "name" -> "ThinkPad X201s"))
  .add(Map("id"->"002", "manu" -> "Lenovo", "name" -> "ThinkPad X220"))
  .add(Map("id"->"003", "manu" -> "Lenovo", "name" -> "ThinkPad X121e"))
  .commit

// query
val result: List[Map[String, Any]] =
  client.query("name:%name%")
    .fields("id", "manu", "name")
    .sortBy("id", Order.asc)
    .getResult(Map("name" -> "ThinkPad"))

result.foreach { doc: Map[String, Any] =>
  println("id: " + doc("id"))
  println("  manu: " + doc("manu"))
  println("  name: " + doc("name"))
}
Here is the list of features that Takezoe wants to add before release:

  •     Mapping document to case class
  •     Flexible configuration to SolrServer
  •     Facet search

Build and launch faster with Okta’s user management API. Register today for the free forever developer edition!

Topics:

Opinions expressed by DZone contributors are their own.

{{ parent.title || parent.header.title}}

{{ parent.tldr }}

{{ parent.urlSource.name }}