Commit 40b7f781ac0db7eb60e4e50d15db7b9fcc8403de
1 parent
71b816c3
Exists in
master
and in
28 other branches
Update acts_as_solr_reloaded
Showing
4 changed files
with
8 additions
and
6 deletions
Show diff stats
plugins/solr/vendor/plugins/acts_as_solr_reloaded/lib/acts_as_solr/class_methods.rb
| ... | ... | @@ -273,7 +273,8 @@ module ActsAsSolr #:nodoc: |
| 273 | 273 | end |
| 274 | 274 | |
| 275 | 275 | if items_processed > 0 |
| 276 | - solr_optimize | |
| 276 | + # FIXME: not recommended, reenable with option | |
| 277 | + #solr_optimize | |
| 277 | 278 | time_elapsed = Time.now - start_time |
| 278 | 279 | logger.info "Index for #{self.name} has been rebuilt (took #{'%.3f' % time_elapsed}s)" |
| 279 | 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 | 40 | doc.boost = validate_boost(configuration[:boost]) if configuration[:boost] |
| 41 | 41 | |
| 42 | 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 | 44 | solr_configuration[:primary_key_field] => record_id(self).to_s} |
| 45 | 45 | |
| 46 | 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 | 127 | classes = [self] + (self.subclasses || []) + (options[:models] || []) |
| 128 | 128 | classes.map do |klass| |
| 129 | 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 | 131 | end.compact.join(' OR ') |
| 132 | 132 | end |
| 133 | 133 | ... | ... |
plugins/solr/vendor/plugins/acts_as_solr_reloaded/lib/solr/util.rb
| ... | ... | @@ -27,11 +27,12 @@ class Solr::Util |
| 27 | 27 | |
| 28 | 28 | # from http://lucene.apache.org/core/old_versioned_docs/versions/3_0_0/queryparsersyntax.html#Escaping Special Characters |
| 29 | 29 | ESCAPES = %w[+ - && || ! ( ) { } \[ \] " ~ * ? \\] |
| 30 | - | |
| 30 | + | |
| 31 | 31 | def self.query_parser_escape(string, fields = []) |
| 32 | - string = string.split(' ').map do |str| | |
| 32 | + string = string.split(' ').map do |str| | |
| 33 | 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 | 36 | elsif /^\^(.*)/ =~ str # escape ^ |
| 36 | 37 | "\\^#{$1}" |
| 37 | 38 | else | ... | ... |