Commit 40b7f781ac0db7eb60e4e50d15db7b9fcc8403de

Authored by Braulio Bhavamitra
1 parent 71b816c3

Update acts_as_solr_reloaded

plugins/solr/vendor/plugins/acts_as_solr_reloaded/lib/acts_as_solr/class_methods.rb
@@ -273,7 +273,8 @@ module ActsAsSolr #:nodoc: @@ -273,7 +273,8 @@ module ActsAsSolr #:nodoc:
273 end 273 end
274 274
275 if items_processed > 0 275 if items_processed > 0
276 - solr_optimize 276 + # FIXME: not recommended, reenable with option
  277 + #solr_optimize
277 time_elapsed = Time.now - start_time 278 time_elapsed = Time.now - start_time
278 logger.info "Index for #{self.name} has been rebuilt (took #{'%.3f' % time_elapsed}s)" 279 logger.info "Index for #{self.name} has been rebuilt (took #{'%.3f' % time_elapsed}s)"
279 else 280 else
plugins/solr/vendor/plugins/acts_as_solr_reloaded/lib/acts_as_solr/instance_methods.rb
@@ -40,7 +40,7 @@ module ActsAsSolr #:nodoc: @@ -40,7 +40,7 @@ module ActsAsSolr #:nodoc:
40 doc.boost = validate_boost(configuration[:boost]) if configuration[:boost] 40 doc.boost = validate_boost(configuration[:boost]) if configuration[:boost]
41 41
42 doc << {:id => solr_id, 42 doc << {:id => solr_id,
43 - solr_configuration[:type_field] => Solr::Util.query_parser_escape(self.class.name), 43 + solr_configuration[:type_field] => self.class.name,
44 solr_configuration[:primary_key_field] => record_id(self).to_s} 44 solr_configuration[:primary_key_field] => record_id(self).to_s}
45 45
46 # iterate through the fields and add them to the document, 46 # iterate through the fields and add them to the document,
plugins/solr/vendor/plugins/acts_as_solr_reloaded/lib/acts_as_solr/parser_methods.rb
@@ -127,7 +127,7 @@ module ActsAsSolr #:nodoc: @@ -127,7 +127,7 @@ module ActsAsSolr #:nodoc:
127 classes = [self] + (self.subclasses || []) + (options[:models] || []) 127 classes = [self] + (self.subclasses || []) + (options[:models] || [])
128 classes.map do |klass| 128 classes.map do |klass|
129 next if klass.name.empty? 129 next if klass.name.empty?
130 - "#{solr_configuration[:type_field]}:\"#{Solr::Util.query_parser_escape klass.name}\"" 130 + "#{solr_configuration[:type_field]}:\"#{klass.name}\""
131 end.compact.join(' OR ') 131 end.compact.join(' OR ')
132 end 132 end
133 133
plugins/solr/vendor/plugins/acts_as_solr_reloaded/lib/solr/util.rb
@@ -27,11 +27,12 @@ class Solr::Util @@ -27,11 +27,12 @@ class Solr::Util
27 27
28 # from http://lucene.apache.org/core/old_versioned_docs/versions/3_0_0/queryparsersyntax.html#Escaping Special Characters 28 # from http://lucene.apache.org/core/old_versioned_docs/versions/3_0_0/queryparsersyntax.html#Escaping Special Characters
29 ESCAPES = %w[+ - && || ! ( ) { } \[ \] " ~ * ? \\] 29 ESCAPES = %w[+ - && || ! ( ) { } \[ \] " ~ * ? \\]
30 - 30 +
31 def self.query_parser_escape(string, fields = []) 31 def self.query_parser_escape(string, fields = [])
32 - string = string.split(' ').map do |str| 32 + string = string.split(' ').map do |str|
33 if /(\w+):(.*)/ =~ str # escape : considering fields 33 if /(\w+):(.*)/ =~ str # escape : considering fields
34 - (!$2.empty? and fields.include?($1.to_sym)) ? "#{$1}:#{$2}" : "#{$1}\\:#{$2}" 34 + field, value = $1, $2
  35 + if field.present? and fields.include?(field.to_sym) then "#{field}:#{value}" else "#{field}\\:#{value.gsub ':', "\\:"}" end
35 elsif /^\^(.*)/ =~ str # escape ^ 36 elsif /^\^(.*)/ =~ str # escape ^
36 "\\^#{$1}" 37 "\\^#{$1}"
37 else 38 else