{"id":84,"date":"2012-01-10T14:53:23","date_gmt":"2012-01-10T19:53:23","guid":{"rendered":"http:\/\/www.thefaberfamily.org\/search-smith\/?p=84"},"modified":"2012-01-16T10:22:15","modified_gmt":"2012-01-16T15:22:15","slug":"coldfusion-9-and-solr-weak-typing-vs-strong","status":"publish","type":"post","link":"http:\/\/www.thefaberfamily.org\/search-smith\/2012\/01\/coldfusion-9-and-solr-weak-typing-vs-strong\/","title":{"rendered":"ColdFusion 9 and Solr: Weak typing vs. strong"},"content":{"rendered":"<p>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 <strong>schema.xml<\/strong> as an &#8220;slong,&#8221; indexed, stored, and required. ColdFusion returned a weird error like the following:<\/p>\n<pre>Error_while_creating_field_user_cnttypeslongproperties=indexedstoredomitNormssortMissingLast_from_value100__orgapachesolrcommonSolrException_Error_while_creating_field<\/pre>\n<p>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 &#8211; using ColdFusion&#8217;s <code>javaCast()<\/code> function when invoking the <code>addField()<\/code> method:<\/p>\n<pre>&lt;cfset temp.addField(\"user_cnt\", javaCast(\"long\", user_cnt)) \/&gt;<\/pre>\n<p>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.<\/p>\n<div class=\"simple_likebuttons_container_small\">\r\n      <div class=\"simple_likebuttons_googleplus\">\r\n        <g:plusone size=\"medium\" count=\"false\" href=\"http:\/\/www.thefaberfamily.org\/search-smith\/2012\/01\/coldfusion-9-and-solr-weak-typing-vs-strong\/\"><\/g:plusone>\r\n      <\/div>\r\n    \r\n      <div class=\"simple_likebuttons_twitter simple_likebuttons_twitter_s\">\r\n        <a href=\"https:\/\/twitter.com\/share\" class=\"twitter-share-button\" data-count=\"none\" data-url=\"http:\/\/www.thefaberfamily.org\/search-smith\/2012\/01\/coldfusion-9-and-solr-weak-typing-vs-strong\/\" data-lang=\"en\">Tweet<\/a>\r\n      <\/div>\r\n    \r\n      <div class=\"simple_likebuttons_facebook\">\r\n        <div id=\"fb-root\"><\/div>\r\n        <script>(function(d, s, id) {\r\n          var js, fjs = d.getElementsByTagName(s)[0];\r\n          if (d.getElementById(id)) {return;}\r\n          js = d.createElement(s); js.id = id;\r\n          js.src = \"\/\/connect.facebook.net\/en_US\/all.js#xfbml=1\";\r\n          fjs.parentNode.insertBefore(js, fjs);\r\n        }(document, \"script\", \"facebook-jssdk\"));<\/script>\r\n        <div class=\"fb-like\" data-href=\"http:\/\/www.thefaberfamily.org\/search-smith\/2012\/01\/coldfusion-9-and-solr-weak-typing-vs-strong\/\" data-send=\"false\" data-layout=\"button_count\" data-show-faces=\"false\" data-width=\"90\"><\/div>\r\n      <\/div>\r\n    <\/div>","protected":false},"excerpt":{"rendered":"<p>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 &#8220;slong,&#8221; 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 [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1,3],"tags":[87,36,47,7,35,88,33,34],"class_list":["post-84","post","type-post","status-publish","format-standard","hentry","category-coldfusion","category-solr","tag-coldfusion","tag-error","tag-integration","tag-java","tag-javacast","tag-solr","tag-strong-typing","tag-weak-typing"],"_links":{"self":[{"href":"http:\/\/www.thefaberfamily.org\/search-smith\/wp-json\/wp\/v2\/posts\/84","targetHints":{"allow":["GET"]}}],"collection":[{"href":"http:\/\/www.thefaberfamily.org\/search-smith\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"http:\/\/www.thefaberfamily.org\/search-smith\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"http:\/\/www.thefaberfamily.org\/search-smith\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"http:\/\/www.thefaberfamily.org\/search-smith\/wp-json\/wp\/v2\/comments?post=84"}],"version-history":[{"count":3,"href":"http:\/\/www.thefaberfamily.org\/search-smith\/wp-json\/wp\/v2\/posts\/84\/revisions"}],"predecessor-version":[{"id":86,"href":"http:\/\/www.thefaberfamily.org\/search-smith\/wp-json\/wp\/v2\/posts\/84\/revisions\/86"}],"wp:attachment":[{"href":"http:\/\/www.thefaberfamily.org\/search-smith\/wp-json\/wp\/v2\/media?parent=84"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"http:\/\/www.thefaberfamily.org\/search-smith\/wp-json\/wp\/v2\/categories?post=84"},{"taxonomy":"post_tag","embeddable":true,"href":"http:\/\/www.thefaberfamily.org\/search-smith\/wp-json\/wp\/v2\/tags?post=84"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}