Search Smith

ColdFusion, SQL queries, and, of course, searching

Posts Tagged ‘integration’

ColdFusion 9 and Solr: MultiValued fields vs. Tokenized

Posted by David Faber on January 17, 2012

I was indexing a new collection yesterday and kept getting out of memory errors from the JVM (in truth, I don’t know if they were from JRun or from whatever JVM Solr was running in). Apparently either CF didn’t like the huge array I was generating, or Solr didn’t like me trying to cram it into a multiValued field of type slong. I decided to try something different – I created a space-delimited list of terms instead (they were all numbers, so no need to worry about phrases or anything like that). That worked great.

According to this question/answer thread on StackOverflow, there should not be a difference in results if that field is used for filtering. There may be a difference in scoring, but as I was only using the field for filtering anyway, that is not a concern.

Posted in ColdFusion, Solr | Tagged: , , , | Leave a Comment »

ColdFusion 9 and Solr: Unusual behavior

Posted by David Faber on January 16, 2012

Over the past week, a colleague of mine and I have noticed some unusual behavior when indexing Solr collections with ColdFusion. We have not been able to figure out the reasons for this behavior, it’s just something we’ve observed. First, the ListToArray() function does not seem to create arrays that are usable with Solr. This behavior has been observed with multiValue fields of both slong and string types. One can get around this by creating a new array, looping over the list, and adding the list elements to the array one by one.

Second, and this is more interesting (confusing?), populating a Solr multiValue field with a ColdFusion array only seems to work properly when a new array is created (using ArrayNew()) for each record being indexed. (I have not tried using implicit array creation (i.e., <cfset recordArr = [] />), so I can’t confirm that this works as well, although there is no reason it shouldn’t.*) Using the same array variable with the ArrayClear() function and repopulating for each record does not work. I can’t think of any explanation for this that actually makes sense.

Third, as I noted before, there are probably typing issues between ColdFusion and Solr that can cause issues as well. The JavaCast() function is helpful in resolving these.

*Update: Implicit array creation does work.

Posted in ColdFusion, Solr | Tagged: , , , , , , , , | Leave a Comment »

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:

Error_while_creating_field_user_cnttypeslongproperties=indexedstoredomitNormssortMissingLast_from_value100__orgapachesolrcommonSolrException_Error_while_creating_field

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 »