Search Smith

ColdFusion, SQL queries, and, of course, searching

Posts Tagged ‘strong typing’

ColdFusion 9 and Solr: Weak typing vs. strong

Posted by David Faber on January 10, 2012

I was trying to index a collection recently, and I kept getting an error when trying to add a value to a particular field. The field in question was defined in schema.xml as an “slong,” indexed, stored, and required. ColdFusion returned a weird error like the following:


So even though the value appeared to be a number, Solr was seeing it as something other than a number. It took me a couple of tweaks, but I finally hit upon a solution to the problem – using ColdFusion’s javaCast() function when invoking the addField() method:

<cfset temp.addField("user_cnt", javaCast("long", user_cnt)) />

The underlying problem is that ColdFusion is weakly-typed, and is quite happy to convert strings to numbers and vice versa, while Java is not.

Posted in ColdFusion, Solr | Tagged: , , , , , , , | 1 Comment »