Faceted Queries on acts_as_solr Associations Comments http://www.chrisumbel.com/article/faceted_queries_acts_as_solr_rails_associations#comments Faceted Queries on acts_as_solr Associations Sun, 05 Feb 2012 02:58:51 GMT Comment by Mazhout on Thu Jul 29 2010 13:51:47 GMT+0000 (UTC) Thanks for this helpful article, I am using acts_as_solr on associations as well but differently. It used to work until I changed the primary keys to string as I needed to generate random ids with uuid-tools. I just got an error because the pk_i key expected is of type int and not a string. I can't change it to string as some of my other models use int ids. Do you have any suggestions by any chance for this problem? Below is the stacktrace: INFO: [] webapp=/solr path=/select params={fl=pk_i,score&wt=ruby&qt=standard&q=(hsbc)+AND+(type_s:CrmCompanyHolding);sh_held_t+desc&rows=200} hits=94 status=0 QTime=137 Jul 29, 2010 9:35:39 PM org.apache.solr.common.SolrException log SEVERE: java.lang.NumberFormatException: For input string: "079e9e96-991e-11df-bcc3-001279deb1c4" Thanks, http://www.chrisumbel.com/article/faceted_queries_acts_as_solr_rails_associations#comments_4c51877375fd7f5381000013 http://www.chrisumbel.com/article/faceted_queries_acts_as_solr_rails_associations#comments_4c51877375fd7f5381000013 Thu, 29 Jul 2010 13:51:47 GMT Comment by Mazhout on Thu Jul 29 2010 14:30:13 GMT+0000 (UTC) Hi, Here is a more precise log: Thanks, (eval):1: syntax error, unexpected tIDENTIFIER, expecting ']' ...94,'docs'=>[{'pk_i'=>[798bc248-9a15-11df-8829-001279deb1c4],... ^ (eval):1: syntax error, unexpected tIDENTIFIER, expecting $end ...ocs'=>[{'pk_i'=>[798bc248-9a15-11df-8829-001279deb1c4],'scor... http://www.chrisumbel.com/article/faceted_queries_acts_as_solr_rails_associations#comments_4c51907575fd7f547f000007 http://www.chrisumbel.com/article/faceted_queries_acts_as_solr_rails_associations#comments_4c51907575fd7f547f000007 Thu, 29 Jul 2010 14:30:13 GMT Comment by Mazhout on Fri Jul 30 2010 01:00:47 GMT+0000 (UTC) Hi, I found the solution: I changed in acts_as_solr/lib/acts_methods the following line: :primary_key_field => "pk_i", to: :primary_key_field => "pk_s", rake solr:reindex and it's ok now, I guess solr can casts id into string. Cheers. http://www.chrisumbel.com/article/faceted_queries_acts_as_solr_rails_associations#comments_4c52243f75fd7f59ed000008 http://www.chrisumbel.com/article/faceted_queries_acts_as_solr_rails_associations#comments_4c52243f75fd7f59ed000008 Fri, 30 Jul 2010 01:00:47 GMT Comment by Mazhout on Fri Jul 30 2010 05:59:33 GMT+0000 (UTC) Ok, So the RIGHT solution is very simple: in my models where the id is a string I just need to add: acts_as_solr :fields => [:category], :primary_key_field => 'pk_s' http://www.chrisumbel.com/article/faceted_queries_acts_as_solr_rails_associations#comments_4c526a4575fd7f5b3d000020 http://www.chrisumbel.com/article/faceted_queries_acts_as_solr_rails_associations#comments_4c526a4575fd7f5b3d000020 Fri, 30 Jul 2010 05:59:33 GMT Comment by Chris Umbel on Fri Jul 30 2010 15:19:59 GMT+0000 (UTC) Sorry I was unable to get back to you. Thanks for posting your solution! http://www.chrisumbel.com/article/faceted_queries_acts_as_solr_rails_associations#comments_4c52ed9f75fd7f6168000017 http://www.chrisumbel.com/article/faceted_queries_acts_as_solr_rails_associations#comments_4c52ed9f75fd7f6168000017 Fri, 30 Jul 2010 15:19:59 GMT