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.
This entry was posted on January 16, 2012 at 8:58 am and is filed under ColdFusion, Solr. Tagged: arrayClear, arrayNew, ColdFusion, error, index, integration, javaCast, listToArray, Solr. You can follow any responses to this entry through the RSS 2.0 feed. You can leave a response, or trackback from your own site.

Leave a Comment