diff -Naur vendor/plugins/orig_acts_as_solr/trunk/lib/acts_methods.rb vendor/plugins/acts_as_solr/lib/acts_methods.rb --- vendor/plugins/orig_acts_as_solr/trunk/lib/acts_methods.rb 2007-09-05 14:09:05.000000000 +0530 +++ vendor/plugins/acts_as_solr/lib/acts_methods.rb 2007-09-05 14:14:05.000000000 +0530 @@ -117,6 +117,7 @@ :include => nil, :facets => nil, :boost => nil, + :custom_schema=>nil, :if => "true" } self.solr_configuration = { @@ -174,4 +175,4 @@ end end -end \ No newline at end of file +end diff -Naur vendor/plugins/orig_acts_as_solr/trunk/lib/class_methods.rb vendor/plugins/acts_as_solr/lib/class_methods.rb --- vendor/plugins/orig_acts_as_solr/trunk/lib/class_methods.rb 2007-09-05 14:09:05.000000000 +0530 +++ vendor/plugins/acts_as_solr/lib/class_methods.rb 2007-09-05 14:10:18.000000000 +0530 @@ -154,5 +154,4 @@ logger.debug items_processed > 0 ? "Index for #{self.name} has been rebuilt" : "Nothing to index for #{self.name}" end end - -end \ No newline at end of file +end diff -Naur vendor/plugins/orig_acts_as_solr/trunk/lib/common_methods.rb vendor/plugins/acts_as_solr/lib/common_methods.rb --- vendor/plugins/orig_acts_as_solr/trunk/lib/common_methods.rb 2007-09-05 14:09:05.000000000 +0530 +++ vendor/plugins/acts_as_solr/lib/common_methods.rb 2007-09-05 14:10:29.000000000 +0530 @@ -73,4 +73,4 @@ end -end \ No newline at end of file +end diff -Naur vendor/plugins/orig_acts_as_solr/trunk/lib/instance_methods.rb vendor/plugins/acts_as_solr/lib/instance_methods.rb --- vendor/plugins/orig_acts_as_solr/trunk/lib/instance_methods.rb 2007-09-05 14:09:05.000000000 +0530 +++ vendor/plugins/acts_as_solr/lib/instance_methods.rb 2007-09-05 19:07:16.000000000 +0530 @@ -4,6 +4,7 @@ # Solr id is : to be unique across all models def solr_id + return "#{record_id(self)}" if configuration[:custom_schema] "#{self.class.name}:#{record_id(self)}" end @@ -32,8 +33,8 @@ doc.boost = validate_boost(configuration[:boost]) if configuration[:boost] doc << {:id => solr_id, - solr_configuration[:type_field] => self.class.name, solr_configuration[:primary_key_field] => record_id(self).to_s} + doc << {solr_configuration[:type_field] => self.class.name} unless configuration[:custom_schema] # iterate through the fields and add them to the document, configuration[:solr_fields].each do |field| @@ -63,6 +64,7 @@ [value].flatten.each do |v| v = set_value_if_nil(suffix) if value.to_s == "" field = Solr::Field.new("#{field_name}_#{suffix}" => ERB::Util.html_escape(v.to_s)) + field = Solr::Field.new("#{field_name}" => ERB::Util.html_escape(v.to_s)) if configuration[:custom_schema] field.boost = validate_boost(field_boost) doc << field end @@ -128,4 +130,4 @@ end end -end \ No newline at end of file +end diff -Naur vendor/plugins/orig_acts_as_solr/trunk/lib/parser_methods.rb vendor/plugins/acts_as_solr/lib/parser_methods.rb --- vendor/plugins/orig_acts_as_solr/trunk/lib/parser_methods.rb 2007-09-05 14:09:05.000000000 +0530 +++ vendor/plugins/acts_as_solr/lib/parser_methods.rb 2007-09-08 19:49:00.000000000 +0530 @@ -6,7 +6,7 @@ # Method used by mostly all the ClassMethods when doing a search def parse_query(query=nil, options={}, models=nil) - valid_options = [:offset, :limit, :facets, :models, :results_format, :order, :scores, :operator] + valid_options = [:offset, :limit, :facets, :models, :results_format, :order, :scores, :operator, :facet_limit] query_options = {} return if query.nil? raise "Invalid parameters: #{(options.keys - valid_options).join(',')}" unless (options.keys - valid_options).empty? @@ -19,18 +19,24 @@ # first steps on the facet parameter processing if options[:facets] query_options[:facets] = {} - query_options[:facets][:limit] = -1 # TODO: make this configurable + query_options[:facets][:limit] = options[:facet_limit]||-1 # TODO: make this configurable query_options[:facets][:sort] = :count if options[:facets][:sort] query_options[:facets][:mincount] = 0 query_options[:facets][:mincount] = 1 if options[:facets][:zeros] == false - query_options[:facets][:fields] = options[:facets][:fields].collect{|k| "#{k}_facet"} if options[:facets][:fields] - query_options[:filter_queries] = replace_types(options[:facets][:browse].collect{|k| "#{k.sub!(/ *: */,"_facet:")}"}) if options[:facets][:browse] - query_options[:facets][:queries] = replace_types(options[:facets][:query].collect{|k| "#{k.sub!(/ *: */,"_t:")}"}) if options[:facets][:query] + if configuration[:custom_schema] + query_options[:facets][:fields] = options[:facets][:fields].collect{|k| "#{k}"} if options[:facets][:fields] + query_options[:filter_queries] = replace_types(options[:facets][:browse].collect{|k| "#{k.sub!(/ *: */,":")}"}) if options[:facets][:browse] + query_options[:facets][:queries] = replace_types(options[:facets][:query].collect{|k| "#{k.sub!(/ *: */,":")}"}) if options[:facets][:query] + else + query_options[:facets][:fields] = options[:facets][:fields].collect{|k| "#{k}_facet"} if options[:facets][:fields] + query_options[:filter_queries] = replace_types(options[:facets][:browse].collect{|k| "#{k.sub!(/ *: */,"_facet:")}"}) if options[:facets][:browse] + query_options[:facets][:queries] = replace_types(options[:facets][:query].collect{|k| "#{k.sub!(/ *: */,"_t:")}"}) if options[:facets][:query] + end end if models.nil? # TODO: use a filter query for type, allowing Solr to cache it individually - models = "AND #{solr_configuration[:type_field]}:#{self.name}" + models = configuration[:custom_schema] ? "" : "AND #{solr_configuration[:type_field]}:#{self.name}" field_list = solr_configuration[:primary_key_field] else field_list = "id" @@ -94,12 +100,12 @@ field_type = get_solr_field_type(:text) if solr_field.is_a?(Hash) solr_field.each do |name,value| - if value.respond_to?(:each_pair) + if value.respond_to?(:each_pair) field_type = get_solr_field_type(value[:type]) if value[:type] else field_type = get_solr_field_type(value) end - field = "#{name.to_s}_#{field_type}#{suffix}" + field = configuration[:custom_schema] ? "#{name.to_s}#{suffix}" : "#{name.to_s}_#{field_type}#{suffix}" strings.each_with_index {|s,i| strings[i] = s.gsub(/#{name.to_s}_t#{suffix}/,field) } end end @@ -122,4 +128,4 @@ end end -end \ No newline at end of file +end