Update data in Solr from Scala

Updating or adding fields in Solr is a little trickier than inserting new documents. When you add documents to Solr through the API, it can create all the fields you send automatically – these will end up in a file called “managed-schema”. This is a neat feature, but it doesn’t occur by default when you […]

Fixing scala error: bad symbolic reference

If you write Scala code, you’re almost guaranteed to end up with incompatible class files somewhere in the chain. This is particularly irritating when it happens within libraries you don’t control, because the scala compiler apparently decides not to give you any useful information, like so: [error] bad symbolic reference. A signature in DefaultWrites.class refers […]

Scala: Read JSON from Solr

The Scala play library has a library for creating and reading JSON. To import it you can add a couple lines in SBT: libraryDependencies += "" %% "play-json" % "2.4.6" libraryDependencies += "org.scalaj" %% "scalaj-http" % "2.3.0" To hit Solr, you can build a URL and pull the result with the HTTP library I imported: […]

Scala: match on value

IF you want to match on a value in Scala you can do so simply. Here, I’m using it to handle commands from RabbitMQ in this format: index, update,,12345 Here is the code: val items = message.split(",") val command = items(0);   command match { case "index" => { val domain = items(1) … } […]