diff --git a/vendor/plugins/acts_as_solr_reloaded/.gitignore b/vendor/plugins/acts_as_solr_reloaded/.gitignore index c855325..95c7b4a 100644 --- a/vendor/plugins/acts_as_solr_reloaded/.gitignore +++ b/vendor/plugins/acts_as_solr_reloaded/.gitignore @@ -1,17 +1,29 @@ +# inside solr +solr/LICENSE.txt +solr/NOTICE.txt +solr/README.txt +solr/etc/ +solr/work/ +solr/lib/ +solr/solr/README.txt +solr/solr/solr.xml +solr/start.jar +solr/webapps/ +solr/solr/data/* + +acts_as_solr_reloaded-*.gem *.log *.log *_pid + +coverage coverage/* coverage.data -solr/solr/data/* -.svn test/db/*.db test/log/*.log pkg/* *.sw? -.DS_Store -coverage rdoc pkg -acts_as_solr_reloaded-*.gem tags +.svn diff --git a/vendor/plugins/acts_as_solr_reloaded/README.markdown b/vendor/plugins/acts_as_solr_reloaded/README.markdown index 9d2f240..2bdd8f9 100644 --- a/vendor/plugins/acts_as_solr_reloaded/README.markdown +++ b/vendor/plugins/acts_as_solr_reloaded/README.markdown @@ -13,19 +13,20 @@ Install as a plugin script/plugin install git://github.com/brauliobo/acts_as_solr_reloaded.git -Download Solr 3.1 +Download Solr 3.5 rake solr:download Requirements ------ -* Java Runtime Environment(JRE) 1.6 aka 6.0 or newer [http://www.java.com/en/download/index.jsp](http://www.java.com/en/download/index.jsp) (use default-jre for Debian like distribution) -* (Recommended) If you have libxml-ruby installed, make sure it's at least version 0.7 +* Java Runtime Environment(JRE) 6.0 (or newer) from Oracle or OpenJDK Configuration ====== See config/solr.yml file. +For solr configuration the important files are solrconfig.xml and schema.xml. + Basic Usage ======

@@ -42,13 +43,21 @@ Basic Usage
 
 
+Pagination +====== +ActsAsSolr implements in SearchResults class an interface compatible with will_paginate and maybe others. -`acts_as_solr` in your tests +In your tests ====== -To test code that uses `acts_as_solr` you must start a Solr server for the test environment. You can do that with `rake solr:start RAILS_ENV=test` +To test code that uses `acts_as_solr` you must start a Solr server for the test environment. +You can add to the beggining of your test/test_helper.rb the code: +

+ENV["RAILS_ENV"] = "test"
+abort unless system 'rake solr:start' 
+at_exit { system 'rake solr:stop' }
+
However, if you would like to mock out Solr calls so that a Solr server is not needed (and your tests will run much faster), just add this to your `test_helper.rb` or similar: -

 class ActsAsSolr::Post
   def self.execute(request)
@@ -57,8 +66,6 @@ class ActsAsSolr::Post
 end
 
-([via](http://www.subelsky.com/2007/10/actsassolr-capistranhttpwwwbloggercomim.html#c1646308013209805416)) - Release Information ====== Released under the MIT license. diff --git a/vendor/plugins/acts_as_solr_reloaded/README.rdoc b/vendor/plugins/acts_as_solr_reloaded/README.rdoc deleted file mode 100644 index 08d77e0..0000000 --- a/vendor/plugins/acts_as_solr_reloaded/README.rdoc +++ /dev/null @@ -1,96 +0,0 @@ -= DESCRIPTION - -This plugin adds full text search capabilities and many other nifty features from Apache's Solr[http://lucene.apache.org/solr/] to any Rails model, like: - -* faceting -* dynamic attributes -* integration with acts_as_taggable_on -* integration with will_paginate -* highlighting -* geolocation -* relevance -* suggest - -Watch this screencast for a short demo of the latests features: - -http://www.vimeo.com/8728276 - -== INSTALLATION - - script/plugin install git://github.com/brauliobo/acts_as_solr_reloaded.git - rake solr:download - -== REQUIREMENTS - -* Java Runtime Environment(JRE) 1.5 aka 5.0 [http://www.java.com/en/download/index.jsp](http://www.java.com/en/download/index.jsp) (use default-jre for Debian like distribution) -* (Recommended) If you have libxml-ruby installed, make sure it's at least version 0.7 - -== CONFIGURATION - -See config/solr.yml file. - -== USAGE - -Just include the line below to any of your ActiveRecord models: - acts_as_solr - -Or if you want, you can specify only the fields that should be indexed: - acts_as_solr :fields => [:name, :author] - -Then to find instances of your model, just do: - Model.search(query) #query is a string representing your query - -Case you want to use dynamic attributes or geolocalization, you can use this generators that setup the database: - - script/generate dynamic_attributes_migration - script/generate local_migration - -and then configure your model like this: - - acts_as_solr :dynamic_attributes => true, - :spatial => true - -If you want to integrate the model with acts_as_taggable_on, just add the option :taggable => true : - - acts_as_solr :taggable => true - -Please see ActsAsSolr::ActsMethods for a complete info - -== PAGINATION - -In your controller: - - @search = Product.search "beer", :page => 2, :per_page => 20 - -And in your view: - - will_paginate @search - -== TESTING - -To test code that uses acts_as_solr_reloaded you must start a Solr server for the test environment and also start MongoDB. - -== LICENSE - -(The MIT License) - -Copyright © 2010 - -Permission is hereby granted, free of charge, to any person obtaining -a copy of this software and associated documentation files (the -‘Software’), to deal in the Software without restriction, including -without limitation the rights to use, copy, modify, merge, publish, -distribute, sublicense, and/or sell copies of the Software, and to -permit persons to whom the Software is furnished to do so, subject to -the following conditions: - -The above copyright notice and this permission notice shall be -included in all copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED ‘AS IS’, WITHOUT WARRANTY OF ANY KIND, -EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF -MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. -IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY -CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, -TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE -SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. diff --git a/vendor/plugins/acts_as_solr_reloaded/config/solr.yml b/vendor/plugins/acts_as_solr_reloaded/config/solr.yml index 79779cf..b0c88c5 100644 --- a/vendor/plugins/acts_as_solr_reloaded/config/solr.yml +++ b/vendor/plugins/acts_as_solr_reloaded/config/solr.yml @@ -1,14 +1,22 @@ -# Config file for the acts_as_solr_reloaded plugin. +# Config file for the acts_as_solr plugin. # # If you change the host or port number here, make sure you update # them in your Solr config file development: - url: http://127.0.0.1:8982/solr - -test: - url: http://127.0.0.1:8981/solr + url: http://0.0.0.0:8982/solr + jvm_options: -server -Xmx128M -Xms16M + timeout: 0 production: url: http://127.0.0.1:8983/solr - jvm_options: -server -d64 -Xmx1024M -Xms64M \ No newline at end of file + jvm_options: -server -Xmx192M -Xms64M + timeout: 0 + +test: &TEST + url: http://0.0.0.0:8981/solr + jvm_options: -server -Xmx128M -Xms16M + timeout: 0 + +cucumber: + <<: *TEST diff --git a/vendor/plugins/acts_as_solr_reloaded/config/solr_environment.rb b/vendor/plugins/acts_as_solr_reloaded/config/solr_environment.rb index b5d729b..1c9dbbc 100644 --- a/vendor/plugins/acts_as_solr_reloaded/config/solr_environment.rb +++ b/vendor/plugins/acts_as_solr_reloaded/config/solr_environment.rb @@ -27,7 +27,7 @@ end unless defined? SOLR_PORT config = YAML::load_file(RAILS_ROOT+'/config/solr.yml') - raise("No solr environment defined for RAILS_ENV the #{ENV['RAILS_ENV'].inspect}") unless config[ENV['RAILS_ENV']] + raise("No solr environment defined for RAILS_ENV = #{ENV['RAILS_ENV'].inspect}") unless config[ENV['RAILS_ENV']] SOLR_HOST = ENV['HOST'] || URI.parse(config[ENV['RAILS_ENV']]['url']).host SOLR_PORT = ENV['PORT'] || URI.parse(config[ENV['RAILS_ENV']]['url']).port diff --git a/vendor/plugins/acts_as_solr_reloaded/lib/acts_as_solr.rb b/vendor/plugins/acts_as_solr_reloaded/lib/acts_as_solr.rb index 3a75756..468a47f 100644 --- a/vendor/plugins/acts_as_solr_reloaded/lib/acts_as_solr.rb +++ b/vendor/plugins/acts_as_solr_reloaded/lib/acts_as_solr.rb @@ -19,36 +19,7 @@ require File.dirname(__FILE__) + '/acts_as_solr/deprecation' require File.dirname(__FILE__) + '/acts_as_solr/search_results' require File.dirname(__FILE__) + '/acts_as_solr/lazy_document' require File.dirname(__FILE__) + '/acts_as_solr/mongo_mapper' - -module ActsAsSolr - class Post - class << self - def config - return @config if @config - @config = {} - YAML::load_file("#{Rails.root}/config/solr.yml")[Rails.env].each{ |k,v| @config[k.to_sym] = v } - @config - end - - def options - @options ||= credentials.merge config - end - - def credentials - @credentials ||= {:username => config[:username], :password => config[:password]} - end - - def url(core) - core.nil? ? config[:url] : "#{config[:url]}/#{core}" - end - - def execute(request, core = nil) - connection = Solr::Connection.new(url(core), options) - connection.send request - end - end - end -end +require File.dirname(__FILE__) + '/acts_as_solr/post' # reopen ActiveRecord and include the acts_as_solr method ActiveRecord::Base.extend ActsAsSolr::ActsMethods diff --git a/vendor/plugins/acts_as_solr_reloaded/lib/acts_as_solr/acts_methods.rb b/vendor/plugins/acts_as_solr_reloaded/lib/acts_as_solr/acts_methods.rb index 6a6e406..7bf1763 100644 --- a/vendor/plugins/acts_as_solr_reloaded/lib/acts_as_solr/acts_methods.rb +++ b/vendor/plugins/acts_as_solr_reloaded/lib/acts_as_solr/acts_methods.rb @@ -164,8 +164,11 @@ module ActsAsSolr #:nodoc: # dynamic_attributes: Default false. When true, requires a has_many relationship to a DynamicAttribute # (:name, :value) model. Then, all dynamic attributes will be mapped as normal attributes # in Solr, so you can filter like this: Model.find_by_solr "#{dynamic_attribute.name}:Lorem" + # # taggable: Default false. When true, indexes tags with field name tag. Tags are taken from taggings.tag + # # spatial: Default false. When true, indexes model.local.latitude and model.local.longitude as coordinates. + # def acts_as_solr(options={}, solr_options={}, &deferred_solr_configuration) $solr_indexed_models << self @@ -262,20 +265,23 @@ module ActsAsSolr #:nodoc: :additional_fields => nil, :dynamic_attributes => false, :exclude_fields => [], - :auto_commit => true, + :auto_commit => ['production'].include?(Rails.env) ? false : true, :include => nil, :facets => nil, :boost => nil, :if => "true", :offline => false, - :spatial => false + :spatial => false, } self.solr_configuration = { :type_field => "type_s", :primary_key_field => "pk_s", - :default_boost => 1.0 + :default_boost => 1.0, } + raise "Invalid options: #{(options.keys-configuration.keys).join(',')}" unless (options.keys-configuration.keys).empty? + raise "Invalid solr options: #{(solr_options.keys-solr_configuration.keys).join(',')}" unless (solr_options.keys-solr_configuration.keys).empty? + configuration.update(options) if options.is_a?(Hash) solr_configuration.update(solr_options) if solr_options.is_a?(Hash) Deprecation.validate_index(configuration) @@ -290,8 +296,18 @@ module ActsAsSolr #:nodoc: process_fields(configuration[:additional_fields]) end - if configuration[:include].respond_to?(:each) - process_includes(configuration[:include]) + process_includes(configuration[:include]) if configuration[:include] + end + + def after_save_reindex(associations, options = {}) + Array(associations).each do |association| + after_save do |ar| + if options[:with] == :delayed_job + delay(:run_at => (Date.today+1.day).to_time+4.hours).solr_batch_add_association ar, association + else + solr_batch_add_association ar, association + end + end end end @@ -301,19 +317,13 @@ module ActsAsSolr #:nodoc: field_name, options = determine_field_name_and_options(field) configuration[:solr_fields][field_name] = options - define_method("#{field_name}_for_solr".to_sym) do - begin - value = self[field_name] || self.instance_variable_get("@#{field_name.to_s}".to_sym) || self.send(field_name.to_sym) - case options[:type] - # format dates properly; return nil for nil dates - when :date - value ? (value.respond_to?(:utc) ? value.utc : value).strftime("%Y-%m-%dT%H:%M:%SZ") : nil - else value - end - rescue - puts $! - logger.debug "There was a problem getting the value for the field '#{field_name}': #{$!}" - value = '' + define_method "#{field_name}_for_solr" do + value = self.send field_name + case options[:type] + when :date # format dates properly; return nil for nil dates + value ? (value.respond_to?(:utc) ? value.utc : value).strftime("%Y-%m-%dT%H:%M:%SZ") : nil + else + value end end end @@ -328,11 +338,9 @@ module ActsAsSolr #:nodoc: end def process_includes(includes) - if includes.respond_to?(:each) - includes.each do |assoc| - field_name, options = determine_field_name_and_options(assoc) - configuration[:solr_includes][field_name] = options - end + Array(includes).each do |assoc| + field_name, options = determine_field_name_and_options(assoc) + configuration[:solr_includes][field_name] = options end end diff --git a/vendor/plugins/acts_as_solr_reloaded/lib/acts_as_solr/class_methods.rb b/vendor/plugins/acts_as_solr_reloaded/lib/acts_as_solr/class_methods.rb index dc74227..c0eb4c3 100644 --- a/vendor/plugins/acts_as_solr_reloaded/lib/acts_as_solr/class_methods.rb +++ b/vendor/plugins/acts_as_solr_reloaded/lib/acts_as_solr/class_methods.rb @@ -197,7 +197,7 @@ module ActsAsSolr #:nodoc: data = parse_query(query, options) data.total_hits end - + # It's used to rebuild the Solr index for a specific model. # Book.rebuild_solr_index # @@ -209,39 +209,75 @@ module ActsAsSolr #:nodoc: # If a finder block is given, it will be called to retrieve the items to index. # This can be very useful for things such as updating based on conditions or # using eager loading for indexed associations. - def rebuild_solr_index(batch_size=100, options = {}, &finder) - finder ||= lambda { |ar, options| ar.find(:all, options.merge({:order => self.primary_key})) } + def rebuild_solr_index(batch_size=300, options = {}, &finder) + finder ||= lambda do |ar, sql_options| + ar.all sql_options.merge!({:order => self.primary_key, :include => configuration[:solr_includes].keys}) + end start_time = Time.now options[:offset] ||= 0 + options[:threads] ||= 2 + options[:delayed_job] &= defined?(Delayed::Job) if batch_size > 0 items_processed = 0 - limit = batch_size offset = options[:offset] - begin - iteration_start = Time.now - items = finder.call(self, {:limit => limit, :offset => offset}) + end_reached = false + threads = [] + mutex = Mutex.new + queue = Queue.new + loop do + items = finder.call(self, {:limit => batch_size, :offset => offset}) add_batch = items.collect { |content| content.to_solr_doc } - - if items.size > 0 - solr_add add_batch - solr_commit - end - - items_processed += items.size - last_id = items.last.id if items.last - time_so_far = Time.now - start_time - iteration_time = Time.now - iteration_start - logger.info "#{Process.pid}: #{items_processed} items for #{self.name} have been batch added to index in #{'%.3f' % time_so_far}s at #{'%.3f' % (items_processed / time_so_far)} items/sec (#{'%.3f' % (items.size / iteration_time)} items/sec for the last batch). Last id: #{last_id}" offset += items.size - end while items.nil? || items.size > 0 + end_reached = items.size == 0 + break if end_reached + + if options[:threads] == threads.size + threads.first.join + threads.shift + end + + queue << [items, add_batch] + threads << Thread.new do + iteration_start = Time.now + + iteration_items, iteration_add_batch = queue.pop(true) + if options[:delayed_job] + delay.solr_add iteration_add_batch + else + solr_add iteration_add_batch + solr_commit + end + + last_id = iteration_items.last.id + time_so_far = Time.now - start_time + iteration_time = Time.now - iteration_start + mutex.synchronize do + items_processed += iteration_items.size + if options[:delayed_job] + logger.info "#{Process.pid}: #{items_processed} items for #{self.name} have been sent to Delayed::Job in #{'%.3f' % time_so_far}s at #{'%.3f' % (items_processed / time_so_far)} items/sec. Last id: #{last_id}" + else + logger.info "#{Process.pid}: #{items_processed} items for #{self.name} have been batch added to index in #{'%.3f' % time_so_far}s at #{'%.3f' % (items_processed / time_so_far)} items/sec. Last id: #{last_id}" + end + end + end + end + + solr_commit if options[:delayed_job] + threads.each{ |t| t.join } else items = finder.call(self, {}) items.each { |content| content.solr_save } items_processed = items.size end - solr_optimize - logger.info items_processed > 0 ? "Index for #{self.name} has been rebuilt" : "Nothing to index for #{self.name}" + + if items_processed > 0 + solr_optimize + time_elapsed = Time.now - start_time + logger.info "Index for #{self.name} has been rebuilt (took #{'%.3f' % time_elapsed}s)" + else + "Nothing to index for #{self.name}" + end end alias :rebuild_index :rebuild_solr_index diff --git a/vendor/plugins/acts_as_solr_reloaded/lib/acts_as_solr/common_methods.rb b/vendor/plugins/acts_as_solr_reloaded/lib/acts_as_solr/common_methods.rb index 4ad7022..5c3a4f3 100644 --- a/vendor/plugins/acts_as_solr_reloaded/lib/acts_as_solr/common_methods.rb +++ b/vendor/plugins/acts_as_solr_reloaded/lib/acts_as_solr/common_methods.rb @@ -1,23 +1,25 @@ module ActsAsSolr #:nodoc: module CommonMethods - + + TypeMapping = { + :double => "do", + :float => "f", + :decimal => "f", + :integer => "i", + :boolean => "b", + :string => "s", + :date => "d", + :range_float => "rf", + :range_integer => "ri", + :facet => "facet", + :text => "t", + } + # Converts field types into Solr types def get_solr_field_type(field_type) if field_type.is_a?(Symbol) - h = { - :float => "f", - :decimal => "f", - :integer => "i", - :boolean => "b", - :string => "s", - :date => "d", - :range_float => "rf", - :range_integer => "ri", - :facet => "facet", - :text => "t", - } - t = h[field_type] + t = TypeMapping[field_type] raise "Unknown field_type symbol: #{field_type}" if t.nil? t elsif field_type.is_a?(String) @@ -34,7 +36,7 @@ module ActsAsSolr #:nodoc: return "false" when "s", "t", "d", :date, :string, :text return "" - when "f", "rf", :float, :range_float + when "f", "rf", :float, :range_float, :double, :decimal return 0.00 when "i", "ri", :integer, :range_integer return 0 @@ -42,6 +44,14 @@ module ActsAsSolr #:nodoc: return "" end end + + def solr_batch_add(objects) + solr_add Array(objects).map{ |a| a.to_solr_doc } + end + + def solr_batch_add_association(ar, association) + solr_batch_add ar.send(association) + end # Sends an add command to Solr def solr_add(add_xml) diff --git a/vendor/plugins/acts_as_solr_reloaded/lib/acts_as_solr/deprecation.rb b/vendor/plugins/acts_as_solr_reloaded/lib/acts_as_solr/deprecation.rb index 94d2194..a6343f0 100644 --- a/vendor/plugins/acts_as_solr_reloaded/lib/acts_as_solr/deprecation.rb +++ b/vendor/plugins/acts_as_solr_reloaded/lib/acts_as_solr/deprecation.rb @@ -30,7 +30,7 @@ module ActsAsSolr #:nodoc: end if options[:sort_by] plog "The option :sort_by is deprecated, use :order instead!" - options[:order] ||= options[:sort_by] + options[:sort] ||= options[:sort_by] end if options[:start] plog "The option :start is deprecated, use :offset instead!" diff --git a/vendor/plugins/acts_as_solr_reloaded/lib/acts_as_solr/instance_methods.rb b/vendor/plugins/acts_as_solr_reloaded/lib/acts_as_solr/instance_methods.rb index 31031e8..53f8cbb 100644 --- a/vendor/plugins/acts_as_solr_reloaded/lib/acts_as_solr/instance_methods.rb +++ b/vendor/plugins/acts_as_solr_reloaded/lib/acts_as_solr/instance_methods.rb @@ -45,8 +45,6 @@ module ActsAsSolr #:nodoc: # iterate through the fields and add them to the document, configuration[:solr_fields].each do |field_name, options| - #field_type = configuration[:facets] && configuration[:facets].include?(field) ? :facet : :text - field_boost = options[:boost] || solr_configuration[:default_boost] field_type = get_solr_field_type(options[:type]) solr_name = options[:as] || field_name @@ -66,8 +64,10 @@ module ActsAsSolr #:nodoc: next if value.nil? || value.to_s.strip.empty? [value].flatten.each do |v| v = set_value_if_nil(suffix) if value.to_s == "" - field = Solr::Field.new("#{solr_name}_#{suffix}" => ERB::Util.html_escape(v.to_s)) - field.boost = validate_boost(field_boost) + + field = Solr::Field.new(:name => "#{solr_name}_#{suffix}", :value => ERB::Util.html_escape(v.to_s)) + processed_boost = validate_boost(field_boost) + field.boost = processed_boost if processed_boost != solr_configuration[:default_boost] doc << field end end @@ -78,38 +78,38 @@ module ActsAsSolr #:nodoc: add_tags(doc) add_space(doc) - debug doc.to_xml + debug doc.to_json doc end - + private def debug(text) logger.debug text rescue nil end - + def add_space(doc) if configuration[:spatial] and local - doc << Solr::Field.new("lat" => local.latitude) - doc << Solr::Field.new("lng" => local.longitude) + doc << Solr::Field.new(:name => "lat", :value => local.latitude) + doc << Solr::Field.new(:name => "lng", :value => local.longitude) end end def add_tags(doc) taggings.each do |tagging| - doc << Solr::Field.new("tag_facet" => tagging.tag.name) - doc << Solr::Field.new("tag_t" => tagging.tag.name) + doc << Solr::Field.new(:name => "tag_facet", :value => tagging.tag.name) + doc << Solr::Field.new(:name => "tag_t", :value => tagging.tag.name) end if configuration[:taggable] end def add_dynamic_attributes(doc) dynamic_attributes.each do |attribute| value = ERB::Util.html_escape(attribute.value) - doc << Solr::Field.new("#{attribute.name}_t" => value) - doc << Solr::Field.new("#{attribute.name}_facet" => value) + doc << Solr::Field.new(:name => "#{attribute.name}_t", :value => value) + doc << Solr::Field.new(:name => "#{attribute.name}_facet", :value => value) end if configuration[:dynamic_attributes] end - + def add_includes(doc) if configuration[:solr_includes].respond_to?(:each) configuration[:solr_includes].each do |association, options| @@ -120,12 +120,13 @@ module ActsAsSolr #:nodoc: suffix = get_solr_field_type(field_type) case self.class.reflect_on_association(association).macro when :has_many, :has_and_belongs_to_many - records = self.send(association).to_a + records = self.send(association).compact unless records.empty? records.each {|r| data << include_value(r, options)} - [data].flatten.each do |value| - field = Solr::Field.new("#{field_name}_#{suffix}" => value) - field.boost = validate_boost(field_boost) + Array(data).each do |value| + field = Solr::Field.new(:name => "#{field_name}_#{suffix}", :value => value) + processed_boost = validate_boost(field_boost) + field.boost = processed_boost if processed_boost != solr_configuration[:default_boost] doc << field end end @@ -145,7 +146,13 @@ module ActsAsSolr #:nodoc: elsif options[:using].is_a? Symbol record.send(options[:using]) else - record.attributes.inject([]){|k,v| k << "#{v.first}=#{ERB::Util.html_escape(v.last)}"}.join(" ") + if options[:fields] + fields = {} + options[:fields].each{ |f| fields[f] = record.send(f) } + else + fields = record.attributes + end + fields.map{ |k,v| ERB::Util.html_escape(v) }.join(" ") end end diff --git a/vendor/plugins/acts_as_solr_reloaded/lib/acts_as_solr/parser_methods.rb b/vendor/plugins/acts_as_solr_reloaded/lib/acts_as_solr/parser_methods.rb index 98a2a4d..ea9306c 100644 --- a/vendor/plugins/acts_as_solr_reloaded/lib/acts_as_solr/parser_methods.rb +++ b/vendor/plugins/acts_as_solr_reloaded/lib/acts_as_solr/parser_methods.rb @@ -4,9 +4,10 @@ module ActsAsSolr #:nodoc: # Method used by mostly all the ClassMethods when doing a search def parse_query(query=nil, options={}, models=nil) - valid_options = [ :filter_queries, :offset, :limit, :facets, :models, :results_format, :order, - :scores, :operator, :include, :lazy, :joins, :select, :core, - :around, :relevance, :highlight, :page, :per_page] + valid_options = [ :alternate_query, :boost_functions, :filter_queries, :facets, :models, :sort, + :scores, :operator, :lazy, :core, :latitude, :longitude, :radius, :relevance, :highlight, + :offset, :per_page, :limit, :page, + :results_format, :sql_options] query_options = {} field_list = models.nil? ? solr_configuration[:primary_key_field] : "id" @@ -20,8 +21,7 @@ module ActsAsSolr #:nodoc: query = sanitize_query(query) query_options[:filter_queries].push(solr_type_condition) end - query_options[:query] = query - order = options[:order].split(/\s*,\s*/).collect{|e| e.gsub(/\s+/,'_t ').gsub(/\bscore_t\b/, 'score') }.join(',') if options[:order] + query_options[:query] = "#{options[:alternate_query]} #{query}" raise "Invalid parameters: #{(options.keys - valid_options).join(',')}" unless (options.keys - valid_options).empty? begin @@ -34,8 +34,8 @@ module ActsAsSolr #:nodoc: query = add_relevance query, options[:relevance] - raise "Expecting and array of strings for :filter_queries" unless options[:filter_queries].nil? or options[:filter_queries].kind_of?(Array) - query_options[:filter_queries] += replace_types([*options[:filter_queries]].collect{|k| "#{k.dup.sub!(/ *: */,"_t:")}"}) if options[:filter_queries] + query_options[:filter_queries] += replace_types([*options[:filter_queries]], '') if options[:filter_queries] + query_options[:boost_functions] = replace_types([*options[:boost_functions]], '').join(' ') if options[:boost_functions] # first steps on the facet parameter processing if options[:facets] @@ -47,9 +47,8 @@ module ActsAsSolr #:nodoc: # override the :zeros (it's deprecated anyway) if :mincount exists query_options[:facets][:mincount] = options[:facets][:mincount] if options[:facets][:mincount] 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.dup.sub!(/ *: */,"_t:")}"}) if options[:facets][:browse] - query_options[:facets][:queries] = replace_types(options[:facets][:query].collect{|k| "#{k.dup.sub!(/ *: */,"_t:")}"}) if options[:facets][:query] - + query_options[:filter_queries] += replace_types([*options[:facets][:browse]]) if options[:facets][:browse] + query_options[:facets][:queries] = replace_types(options[:facets][:query]) if options[:facets][:query] if options[:facets][:dates] query_options[:date_facets] = {} @@ -82,28 +81,25 @@ module ActsAsSolr #:nodoc: end end - if options[:highlight] - query_options[:highlighting] = {} - query_options[:highlighting][:field_list] = [] - query_options[:highlighting][:field_list] << options[:highlight][:fields].collect {|k| "#{k}_t"} if options[:highlight][:fields] - query_options[:highlighting][:require_field_match] = options[:highlight][:require_field_match] if options[:highlight][:require_field_match] - query_options[:highlighting][:max_snippets] = options[:highlight][:max_snippets] if options[:highlight][:max_snippets] - query_options[:highlighting][:prefix] = options[:highlight][:prefix] if options[:highlight][:prefix] - query_options[:highlighting][:suffix] = options[:highlight][:suffix] if options[:highlight][:suffix] - end - - # TODO: set the sort parameter instead of the old ;order. style. - query_options[:sort] = replace_types([order], false)[0] if options[:order] - - if options[:around] - query_options[:radius] = options[:around][:radius] - query_options[:latitude] = options[:around][:latitude] - query_options[:longitude] = options[:around][:longitude] + if options[:highlight] + query_options[:highlighting] = {} + query_options[:highlighting][:field_list] = [] + query_options[:highlighting][:field_list] << options[:highlight][:fields].collect {|k| "#{k}_t"} if options[:highlight][:fields] + query_options[:highlighting][:require_field_match] = options[:highlight][:require_field_match] if options[:highlight][:require_field_match] + query_options[:highlighting][:max_snippets] = options[:highlight][:max_snippets] if options[:highlight][:max_snippets] + query_options[:highlighting][:prefix] = options[:highlight][:prefix] if options[:highlight][:prefix] + query_options[:highlighting][:suffix] = options[:highlight][:suffix] if options[:highlight][:suffix] end - ActsAsSolr::Post.execute(Solr::Request::Standard.new(query_options), options[:core]) + query_options[:sort] = replace_types([options[:sort]], '')[0] if options[:sort] + + query_options[:radius] = options[:radius] + query_options[:latitude] = options[:latitude] + query_options[:longitude] = options[:longitude] + + ActsAsSolr::Post.execute(Solr::Request::Dismax.new(query_options), options[:core]) rescue - raise "There was a problem executing your search\n#{query_options.inspect}\n: #{$!} in #{$!.backtrace.first}" + raise "#{$query} There was a problem executing your search\n#{query_options.inspect}\n: #{$!} in #{$!.backtrace.first}" end end @@ -158,11 +154,11 @@ module ActsAsSolr #:nodoc: result = if configuration[:lazy] && configuration[:format] != :ids ids.collect {|id| ActsAsSolr::LazyDocument.new(id, self)} elsif configuration[:format] == :objects - find_options = {} - find_options[:include] = options[:include] if options[:include] - find_options[:select] = options[:select] if options[:select] - find_options[:joins] = options[:joins] if options[:joins] - result = reorder(self.find(ids, find_options), ids) + find_options = options[:sql_options] || {} + find_options[:conditions] = self.send :merge_conditions, {:id => ids}, (find_options[:conditions] || []) + result = self.all(find_options) + result = reorder(result, ids) unless find_options[:order] + result else ids end @@ -182,14 +178,13 @@ module ActsAsSolr #:nodoc: # Replaces the field types based on the types (if any) specified # on the acts_as_solr call - def replace_types(strings, include_colon=true) - suffix = include_colon ? ":" : "" + def replace_types(strings, suffix=':') if configuration[:solr_fields] configuration[:solr_fields].each do |name, options| - solr_name = options[:as] || name.to_s + solr_name = (options[:as] || name).to_s solr_type = get_solr_field_type(options[:type]) field = "#{solr_name}_#{solr_type}#{suffix}" - strings.each_with_index {|s,i| strings[i] = s.gsub(/#{solr_name.to_s}_t#{suffix}/,field) } + strings.each_with_index {|s,i| strings[i] = s.gsub(/\b#{solr_name}\b#{suffix}/,field) } end end if configuration[:solr_includes] @@ -197,7 +192,7 @@ module ActsAsSolr #:nodoc: solr_name = options[:as] || association.to_s.singularize solr_type = get_solr_field_type(options[:type]) field = "#{solr_name}_#{solr_type}#{suffix}" - strings.each_with_index {|s,i| strings[i] = s.gsub(/#{solr_name.to_s}_t#{suffix}/,field) } + strings.each_with_index {|s,i| strings[i] = s.gsub(/\b#{solr_name}\b#{suffix}/,field) } end end strings diff --git a/vendor/plugins/acts_as_solr_reloaded/lib/acts_as_solr/post.rb b/vendor/plugins/acts_as_solr_reloaded/lib/acts_as_solr/post.rb new file mode 100644 index 0000000..bd8250f --- /dev/null +++ b/vendor/plugins/acts_as_solr_reloaded/lib/acts_as_solr/post.rb @@ -0,0 +1,29 @@ +module ActsAsSolr + class Post + class << self + def config + return @config if @config + @config = {} + YAML::load_file("#{Rails.root}/config/solr.yml")[Rails.env].each{ |k,v| @config[k.to_sym] = v } + @config + end + + def options + @options ||= credentials.merge config + end + + def credentials + @credentials ||= {:username => config[:username], :password => config[:password]} + end + + def url(core) + core.nil? ? config[:url] : "#{config[:url]}/#{core}" + end + + def execute(request, core = nil) + connection = Solr::Connection.new(url(core), options) + connection.send request + end + end + end +end diff --git a/vendor/plugins/acts_as_solr_reloaded/lib/acts_as_solr/search_results.rb b/vendor/plugins/acts_as_solr_reloaded/lib/acts_as_solr/search_results.rb index c8220bf..c1221aa 100644 --- a/vendor/plugins/acts_as_solr_reloaded/lib/acts_as_solr/search_results.rb +++ b/vendor/plugins/acts_as_solr_reloaded/lib/acts_as_solr/search_results.rb @@ -27,10 +27,17 @@ module ActsAsSolr #:nodoc: # # class SearchResults + + include Enumerable + def initialize(solr_data={}) @solr_data = solr_data end + def each(&block) + self.results.each &block + end + # Returns an array with the instances. This method # is also aliased as docs and records def results @@ -60,7 +67,7 @@ module ActsAsSolr #:nodoc: # Returns the highlighted fields which one has asked for.. def highlights - @solr_data[:highlights] + @solr_data[:highlights] end # Returns a suggested query @@ -83,10 +90,45 @@ module ActsAsSolr #:nodoc: (@solr_data[:start].to_i / per_page) + 1 end + def blank? + total_entries == 0 + end + + def size + total_entries + end + + def offset + (current_page - 1) * per_page + end + + def previous_page + if current_page > 1 + current_page - 1 + else + false + end + end + + def next_page + if current_page < total_pages + current_page + 1 + else + false + end + end + + def method_missing(symbol, *args, &block) + self.results.send(symbol, *args, &block) + rescue NoMethodError + raise NoMethodError, "There is no method called #{symbol} at #{self.class.name} - #{self.inspect}" + end + alias docs results alias records results alias num_found total alias total_hits total + alias total_entries total alias highest_score max_score end diff --git a/vendor/plugins/acts_as_solr_reloaded/lib/solr/connection.rb b/vendor/plugins/acts_as_solr_reloaded/lib/solr/connection.rb index 1adb92b..65c1ee3 100755 --- a/vendor/plugins/acts_as_solr_reloaded/lib/solr/connection.rb +++ b/vendor/plugins/acts_as_solr_reloaded/lib/solr/connection.rb @@ -40,8 +40,8 @@ class Solr::Connection # Not actually opening the connection yet, just setting up the persistent connection. @connection = Net::HTTP.new(@url.host, @url.port) - - @connection.read_timeout = opts[:timeout] if opts[:timeout] + + @connection.read_timeout = opts[:timeout].to_i || 0 @username = opts[:username] if opts[:username] @password = opts[:password] if opts[:password] end diff --git a/vendor/plugins/acts_as_solr_reloaded/lib/solr/document.rb b/vendor/plugins/acts_as_solr_reloaded/lib/solr/document.rb index 3c91f4e..7d69631 100644 --- a/vendor/plugins/acts_as_solr_reloaded/lib/solr/document.rb +++ b/vendor/plugins/acts_as_solr_reloaded/lib/solr/document.rb @@ -18,7 +18,7 @@ class Solr::Document # Create a new Solr::Document, optionally passing in a hash of # key/value pairs for the fields # - # doc = Solr::Document.new(:creator => 'Jorge Luis Borges') + # doc = Solr::Document.new(:name => :creator, :value => 'Jorge Luis Borges') def initialize(hash={}) @fields = [] self << hash @@ -26,19 +26,19 @@ class Solr::Document # Append a Solr::Field # - # doc << Solr::Field.new(:creator => 'Jorge Luis Borges') + # doc << Solr::Field.new(:name => :creator, :value => 'Jorge Luis Borges') # # If you are truly lazy you can simply pass in a hash: # - # doc << {:creator => 'Jorge Luis Borges'} + # doc << {:name => :creator, :value => 'Jorge Luis Borges'} def <<(fields) case fields when Hash fields.each_pair do |name,value| if value.respond_to?(:each) && !value.is_a?(String) - value.each {|v| @fields << Solr::Field.new(name => v)} + value.each {|v| @fields << Solr::Field.new(:name => name, :value => v)} else - @fields << Solr::Field.new(name => value) + @fields << Solr::Field.new(:name => name, :value => value) end end when Solr::Field @@ -58,10 +58,20 @@ class Solr::Document # shorthand to assign as a hash def []=(name,value) - @fields << Solr::Field.new(name => value) + @fields << Solr::Field.new(:name => name, :value => value) + end + + def to_jsonhash + hash = {'doc' => {}} + hash['boost'] = @boost if @boost + @fields.each{ |f| hash['doc'][f.name] = f.value_to_jsonhash } + hash + end + + def to_json + to_jsonhash.to_json end - # convert the Document to a REXML::Element def to_xml e = Solr::XML::Element.new 'doc' e.attributes['boost'] = @boost.to_s if @boost diff --git a/vendor/plugins/acts_as_solr_reloaded/lib/solr/field.rb b/vendor/plugins/acts_as_solr_reloaded/lib/solr/field.rb index f7bc8dd..2601a5a 100644 --- a/vendor/plugins/acts_as_solr_reloaded/lib/solr/field.rb +++ b/vendor/plugins/acts_as_solr_reloaded/lib/solr/field.rb @@ -18,18 +18,22 @@ class Solr::Field # Accepts an optional :boost parameter, used to boost the relevance of a particular field. def initialize(params) - @boost = params[:boost] - name_key = (params.keys - VALID_PARAMS).first - @name, @value = name_key.to_s, params[name_key] + @boost = params[:boost] == 1.0 ? nil : params[:boost] + @name = params[:name].to_s + @value = params[:value] # Convert any Time values into UTC/XML schema format (which Solr requires). - @value = @value.respond_to?(:utc) ? @value.utc.xmlschema : @value.to_str + @value = @value.respond_to?(:utc) ? @value.utc.xmlschema : @value end + def value_to_jsonhash + @boost.nil? ? @value : {'boost' => @boost, 'value' => @value} + end + def to_xml e = Solr::XML::Element.new 'field' e.attributes['name'] = @name e.attributes['boost'] = @boost.to_s if @boost - e.text = @value + e.text = @value.to_str return e end diff --git a/vendor/plugins/acts_as_solr_reloaded/lib/solr/request/add_document.rb b/vendor/plugins/acts_as_solr_reloaded/lib/solr/request/add_document.rb index 699d2dd..6e0b9af 100644 --- a/vendor/plugins/acts_as_solr_reloaded/lib/solr/request/add_document.rb +++ b/vendor/plugins/acts_as_solr_reloaded/lib/solr/request/add_document.rb @@ -10,19 +10,19 @@ # See the License for the specific language governing permissions and # limitations under the License. -class Solr::Request::AddDocument < Solr::Request::Update +class Solr::Request::AddDocument < Solr::Request::JsonUpdate # create the request, optionally passing in a Solr::Document # - # request = Solr::Request::AddDocument.new doc + # request = Solr::Request::AddDocument.new(doc) # # as a short cut you can pass in a Hash instead: # - # request = Solr::Request::AddDocument.new :creator => 'Jorge Luis Borges' + # request = Solr::Request::AddDocument.new(:creator => 'Jorge Luis Borges') # # or an array, to add multiple documents at the same time: # - # request = Solr::Request::AddDocument.new([doc1, doc2, doc3]) + # request = Solr::Request::AddDocument.new([doc1, doc2, doc3])) def initialize(doc={}) @docs = [] @@ -33,15 +33,23 @@ class Solr::Request::AddDocument < Solr::Request::Update end end - # returns the request as a string suitable for posting - - def to_s + def to_json + '{' + + @docs.map{ |doc| "\"add\": #{doc.to_jsonhash.to_json}" }.join(',') + + '}' + end + + def to_xml e = Solr::XML::Element.new 'add' for doc in @docs e.add_element doc.to_xml end return e.to_s end + + def to_s + to_json + end private def add_doc(doc) diff --git a/vendor/plugins/acts_as_solr_reloaded/lib/solr/request/dismax.rb b/vendor/plugins/acts_as_solr_reloaded/lib/solr/request/dismax.rb index 13d1977..031a0fb 100644 --- a/vendor/plugins/acts_as_solr_reloaded/lib/solr/request/dismax.rb +++ b/vendor/plugins/acts_as_solr_reloaded/lib/solr/request/dismax.rb @@ -13,34 +13,25 @@ class Solr::Request::Dismax < Solr::Request::Standard VALID_PARAMS.replace(VALID_PARAMS + [:tie_breaker, :query_fields, :minimum_match, :phrase_fields, :phrase_slop, - :boost_query, :boost_functions]) + :alternate_query, :boost_query, :boost_functions]) def initialize(params) - @alternate_query = params.delete(:alternate_query) - @sort_values = params.delete(:sort) - - super - - @query_type = "dismax" + super("search") end def to_hash hash = super + hash[:defType] = 'edismax' hash[:tie] = @params[:tie_breaker] hash[:mm] = @params[:minimum_match] hash[:qf] = @params[:query_fields] hash[:pf] = @params[:phrase_fields] hash[:ps] = @params[:phrase_slop] hash[:bq] = @params[:boost_query] - hash[:bf] = @params[:boost_functions] - hash["q.alt"] = @alternate_query - # FIXME: 2007-02-13 -- This code is duplicated in - # Solr::Request::Standard. It should be refactored into a single location. - hash[:sort] = @sort_values.collect do |sort| - key = sort.keys[0] - "#{key.to_s} #{sort[key] == :descending ? 'desc' : 'asc'}" - end.join(',') if @sort_values + hash[:boost] = @params[:boost_functions] + hash["q.alt"] = @params[:alternate_query] + return hash end -end \ No newline at end of file +end diff --git a/vendor/plugins/acts_as_solr_reloaded/lib/solr/request/standard.rb b/vendor/plugins/acts_as_solr_reloaded/lib/solr/request/standard.rb index 895866f..5473fad 100755 --- a/vendor/plugins/acts_as_solr_reloaded/lib/solr/request/standard.rb +++ b/vendor/plugins/acts_as_solr_reloaded/lib/solr/request/standard.rb @@ -14,10 +14,10 @@ class Solr::Request::Standard < Solr::Request::Select VALID_PARAMS = [:query, :sort, :default_field, :operator, :start, :rows, :shards, :date_facets, :filter_queries, :field_list, :debug_query, :explain_other, :facets, :highlighting, :mlt, :radius, - :latitude, :longitude, :spellcheck] + :radius, :latitude, :longitude, :spellcheck] def initialize(params) - super(params[:radius].nil? ? 'standard' : 'geo') + super('search') raise "Invalid parameters: #{(params.keys - VALID_PARAMS).join(',')}" unless (params.keys - VALID_PARAMS).empty? @@ -51,6 +51,7 @@ class Solr::Request::Standard < Solr::Request::Select hash[:q] = @params[:query] hash["q.op"] = @params[:operator] hash[:df] = @params[:default_field] + hash[:echoParams] = 'explicit' # common parameter processing hash[:start] = @params[:start] @@ -61,11 +62,9 @@ class Solr::Request::Standard < Solr::Request::Select hash[:explainOther] = @params[:explain_other] hash[:shards] = @params[:shards].join(',') unless @params[:shards].empty? - #if @params[:qt].eql? 'geo' - hash[:radius] = @params[:radius] - hash[:lat] = @params[:latitude] - hash[:long] = @params[:longitude] - #end + hash[:sfield] = 'latlng' + hash[:d] = @params[:radius] + hash[:pt] = "#{@params[:latitude]}, #{@params[:longitude]}" # facet parameter processing if @params[:facets] diff --git a/vendor/plugins/acts_as_solr_reloaded/lib/solr/solrtasks.rb b/vendor/plugins/acts_as_solr_reloaded/lib/solr/solrtasks.rb deleted file mode 100755 index 3a1f76a..0000000 --- a/vendor/plugins/acts_as_solr_reloaded/lib/solr/solrtasks.rb +++ /dev/null @@ -1,27 +0,0 @@ -#!/usr/bin/env ruby -# The ASF licenses this file to You under the Apache License, Version 2.0 -# (the "License"); you may not use this file except in compliance with -# the License. You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. - -# TODO: fill out Solr tasks: start, stop, ping, optimize, etc. - -require 'rake' -require 'rake/tasklib' - -module Solr - namespace :solr do - desc "Start Solr" - task :start do - # TODO: actually start it up! - puts "Starting..." - end - end -end diff --git a/vendor/plugins/acts_as_solr_reloaded/lib/tasks/solr.rake b/vendor/plugins/acts_as_solr_reloaded/lib/tasks/solr.rake index d5a950a..a743707 100644 --- a/vendor/plugins/acts_as_solr_reloaded/lib/tasks/solr.rake +++ b/vendor/plugins/acts_as_solr_reloaded/lib/tasks/solr.rake @@ -93,6 +93,12 @@ namespace :solr do puts "PID file not found at #{SOLR_PID_FILE}. Either Solr is not running or no PID file was written." end end + + desc 'Restart Solr. Specify the environment by using: RAILS_ENV=your_env. Defaults to development if none.' + task :restart => :environment do + Rake::Task["solr:stop"].invoke + Rake::Task["solr:start"].invoke + end desc 'Remove Solr index' task :destroy_index => :environment do @@ -111,39 +117,45 @@ namespace :solr do task :reindex => :environment do require File.expand_path("#{File.dirname(__FILE__)}/../../config/solr_environment") - optimize = env_to_bool('OPTIMIZE', true) + delayed_job = env_to_bool('DELAYED_JOB', false) + optimize = env_to_bool('OPTIMIZE', !delayed_job) start_server = env_to_bool('START_SERVER', false) offset = ENV['OFFSET'].to_i.nonzero? || 0 clear_first = env_to_bool('CLEAR', offset == 0) batch_size = ENV['BATCH'].to_i.nonzero? || 300 debug_output = env_to_bool("DEBUG", false) + models = (ENV['MODELS'] || '').split(',').map{ |m| m.constantize } + threads = (ENV['THREADS'] || '2').to_i logger = ActiveRecord::Base.logger = Logger.new(STDOUT) logger.level = ActiveSupport::BufferedLogger::INFO unless debug_output + Dir["#{Rails.root}/app/models/*.rb"].each{ |file| require file } if start_server puts "Starting Solr server..." Rake::Task["solr:start"].invoke end - # Disable solr_optimize + # Disable optimize and commit module ActsAsSolr::CommonMethods def blank() end alias_method :deferred_solr_optimize, :solr_optimize alias_method :solr_optimize, :blank + alias_method :solr_commit, :blank end - $solr_indexed_models.each do |model| - + models = $solr_indexed_models unless models.count > 0 + models.each do |model| if clear_first puts "Clearing index for #{model}..." - #ActsAsSolr::Post.execute(Solr::Request::Delete.new(:query => "#{model.solr_configuration[:type_field]}:#{model}")) - #ActsAsSolr::Post.execute(Solr::Request::Commit.new) + ActsAsSolr::Post.execute(Solr::Request::Delete.new(:query => "#{model.solr_configuration[:type_field]}:#{model}")) + ActsAsSolr::Post.execute(Solr::Request::Commit.new) end puts "Rebuilding index for #{model}..." - model.rebuild_solr_index batch_size, :offset => offset - + model.rebuild_solr_index batch_size, :offset => offset, :threads => threads, :delayed_job => delayed_job + puts "Commiting changes..." + ActsAsSolr::Post.execute(Solr::Request::Commit.new) end if $solr_indexed_models.empty? diff --git a/vendor/plugins/acts_as_solr_reloaded/solr/solr/conf/admin-extra.html b/vendor/plugins/acts_as_solr_reloaded/solr/solr/conf/admin-extra.html old mode 100755 new mode 100644 index aa739da..aa739da --- a/vendor/plugins/acts_as_solr_reloaded/solr/solr/conf/admin-extra.html +++ b/vendor/plugins/acts_as_solr_reloaded/solr/solr/conf/admin-extra.html diff --git a/vendor/plugins/acts_as_solr_reloaded/solr/solr/conf/elevate.xml b/vendor/plugins/acts_as_solr_reloaded/solr/solr/conf/elevate.xml old mode 100755 new mode 100644 index b91e75c..b91e75c --- a/vendor/plugins/acts_as_solr_reloaded/solr/solr/conf/elevate.xml +++ b/vendor/plugins/acts_as_solr_reloaded/solr/solr/conf/elevate.xml diff --git a/vendor/plugins/acts_as_solr_reloaded/solr/solr/conf/mapping-ISOLatin1Accent.txt b/vendor/plugins/acts_as_solr_reloaded/solr/solr/conf/mapping-ISOLatin1Accent.txt old mode 100755 new mode 100644 index c441043..c441043 --- a/vendor/plugins/acts_as_solr_reloaded/solr/solr/conf/mapping-ISOLatin1Accent.txt +++ b/vendor/plugins/acts_as_solr_reloaded/solr/solr/conf/mapping-ISOLatin1Accent.txt diff --git a/vendor/plugins/acts_as_solr_reloaded/solr/solr/conf/protwords.en.txt b/vendor/plugins/acts_as_solr_reloaded/solr/solr/conf/protwords.en.txt new file mode 100644 index 0000000..7ec7867 --- /dev/null +++ b/vendor/plugins/acts_as_solr_reloaded/solr/solr/conf/protwords.en.txt @@ -0,0 +1,19 @@ +# The ASF licenses this file to You under the Apache License, Version 2.0 +# (the "License"); you may not use this file except in compliance with +# the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +#----------------------------------------------------------------------- +# Use a protected word file to protect against the stemmer reducing two +# unrelated words to the same base word. + +# Some non-words that normally won't be encountered, +# just to test that they won't be stemmed. + diff --git a/vendor/plugins/acts_as_solr_reloaded/solr/solr/conf/protwords.pt.txt b/vendor/plugins/acts_as_solr_reloaded/solr/solr/conf/protwords.pt.txt new file mode 100644 index 0000000..7ec7867 --- /dev/null +++ b/vendor/plugins/acts_as_solr_reloaded/solr/solr/conf/protwords.pt.txt @@ -0,0 +1,19 @@ +# The ASF licenses this file to You under the Apache License, Version 2.0 +# (the "License"); you may not use this file except in compliance with +# the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +#----------------------------------------------------------------------- +# Use a protected word file to protect against the stemmer reducing two +# unrelated words to the same base word. + +# Some non-words that normally won't be encountered, +# just to test that they won't be stemmed. + diff --git a/vendor/plugins/acts_as_solr_reloaded/solr/solr/conf/protwords.txt b/vendor/plugins/acts_as_solr_reloaded/solr/solr/conf/protwords.txt deleted file mode 100755 index 5a32e50..0000000 --- a/vendor/plugins/acts_as_solr_reloaded/solr/solr/conf/protwords.txt +++ /dev/null @@ -1,21 +0,0 @@ -# The ASF licenses this file to You under the Apache License, Version 2.0 -# (the "License"); you may not use this file except in compliance with -# the License. You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. - -#----------------------------------------------------------------------- -# Use a protected word file to protect against the stemmer reducing two -# unrelated words to the same base word. - -# Some non-words that normally won't be encountered, -# just to test that they won't be stemmed. -dontstems -zwhacky - diff --git a/vendor/plugins/acts_as_solr_reloaded/solr/solr/conf/schema.xml b/vendor/plugins/acts_as_solr_reloaded/solr/solr/conf/schema.xml old mode 100755 new mode 100644 index bb562cc..3c4ecf5 --- a/vendor/plugins/acts_as_solr_reloaded/solr/solr/conf/schema.xml +++ b/vendor/plugins/acts_as_solr_reloaded/solr/solr/conf/schema.xml @@ -41,7 +41,7 @@ - + @@ -50,24 +50,48 @@ - + + + - + + + + + + + + + - + + + - + + + + + + + + + @@ -93,11 +117,18 @@ + + + + + + + @@ -106,9 +137,10 @@ + - + @@ -125,6 +157,9 @@ id text + + + diff --git a/vendor/plugins/acts_as_solr_reloaded/solr/solr/conf/scripts.conf b/vendor/plugins/acts_as_solr_reloaded/solr/solr/conf/scripts.conf old mode 100755 new mode 100644 index f58b262..f58b262 --- a/vendor/plugins/acts_as_solr_reloaded/solr/solr/conf/scripts.conf +++ b/vendor/plugins/acts_as_solr_reloaded/solr/solr/conf/scripts.conf diff --git a/vendor/plugins/acts_as_solr_reloaded/solr/solr/conf/solrconfig.xml b/vendor/plugins/acts_as_solr_reloaded/solr/solr/conf/solrconfig.xml old mode 100755 new mode 100644 index 3ebd2ea..27150fe --- a/vendor/plugins/acts_as_solr_reloaded/solr/solr/conf/solrconfig.xml +++ b/vendor/plugins/acts_as_solr_reloaded/solr/solr/conf/solrconfig.xml @@ -1,898 +1,1593 @@ - - - - - - ${solr.abortOnConfigurationError:true} - - - ${solr.data.dir:./solr/data} - - - - - false - - 10 - - - - 32 - 2147483647 - 10000 - 1000 - 10000 - - - - - - - - - - - single - - - - - false - 32 - 10 - - - 2147483647 - 10000 - - - false - - - true - - - - - false - - 1 - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 1024 - - - - - - - - - - - - - - - - true - - - - - - - - 50 - - - 200 - - - - - - solr 0 10 - rocks 0 10 - static newSearcher warming query from solrconfig.xml - - - - - - - fast_warm 0 10 - static firstSearcher warming query from solrconfig.xml - - - - - false - - - 2 - - - - - - - - - - - - - - - - - - - - - - - explicit - map - - - - - spellcheck - - - - - - - - - - - - - dismax - explicit - 0.01 - - text^0.5 features^1.0 name^1.2 sku^1.5 id^10.0 manu^1.1 cat^1.4 - - - text^0.2 features^1.1 name^1.5 manu^1.4 manu_exact^1.9 - - - ord(popularity)^0.5 recip(rord(price),1,1000,1000)^0.3 - - - id,name,price,score - - - 2<-1 5<-2 6<90% - - 100 - *:* - - text features name - - 0 - - name - regex - - - - - - - dismax - explicit - text^0.5 features^1.0 name^1.2 sku^1.5 id^10.0 - 2<-1 5<-2 6<90% - - incubationdate_dt:[* TO NOW/DAY-1MONTH]^2.2 - - - - inStock:true - - - - cat - manu_exact - price:[* TO 500] - price:[500 TO *] - - - - - - - - - - textSpell - - - default - spell - ./spellchecker1 - true - true - - - - jarowinkler - spell - org.apache.lucene.search.spell.JaroWinklerDistance - ./spellchecker2 - - - - solr.FileBasedSpellChecker - file - spellings.txt - UTF-8 - ./spellcheckerFile - - - - - - - - false - - false - - 1 - - - spellcheck - - - - - - - - true - - - tvComponent - - - - - - - - - - - - true - - - termsComponent - - - - - - - - string - elevate.xml - - - - - - explicit - - - elevator - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - standard - solrpingquery - all - - - - - - - explicit - true - - - - - - - - - 100 - - - - - - - - 70 - - 0.5 - - [-\w ,/\n\"']{20,200} - - - - - - - ]]> - ]]> - - - - - - - - - - - - - mlt - highlight - debug - - - - - - - - 5 - - - - - - - - - - solr - - - - - + + + + + + + + + ${solr.abortOnConfigurationError:true} + + + LUCENE_35 + + + + + + + + + + + + + + + + + + + + + + + + ${solr.data.dir:} + + + + + + + + + + false + + 10 + + 128 + + 1000 --> + + 1001001 + 1000 + + + + + + + + + native + + + + + + + + + 10 + + 128 + + 1000 --> + + + false + + + true + + + + + 1 + + 0 + + + + + + false + + + + + + + + + + + + + + + + 1000 + 1800000 + + + + + + + + + + + + + + + + + 1024 + + + + + + + + + + + + + + + + + + + + + + true + + + + + + 20 + + + 200 + + + + + + + + + + + + static firstSearcher warming in solrconfig.xml + + + + + + false + + + 4 + + + + + + + + + + + + + + + + + + + + + + + none + 10 + + + + + + + + + + + + + + edismax + none + + + on + text features name + 0 + name + + + + + + + none + + + velocity + + browse + layout + + edismax + 10 + *,score + + + on + text features name + 0 + name + + + spellcheck + + + + + + + + + + + + + + + + + + + + + + + text + true + ignored_ + + + true + links + ignored_ + + + + + + + + + + + + + + + + + + + + + + + + search + solrpingquery + + + all + + + + + + + explicit + true + + + + + + + + + + + + textSpell + + + + + + default + name + spellchecker + + + + + + + + + + + + + + + + + false + false + 1 + + + spellcheck + + + + + + + + + + true + + + tvComponent + + + + + + + + + default + + + org.carrot2.clustering.lingo.LingoClusteringAlgorithm + + + 20 + + + clustering/carrot2 + + + ENGLISH + + + stc + org.carrot2.clustering.stc.STCClusteringAlgorithm + + + + + + + true + default + true + + name + id + + features + + true + + + + false + + edismax + + text^0.5 features^1.0 name^1.2 sku^1.5 id^10.0 manu^1.1 cat^1.4 + + *:* + 10 + *,score + + + clustering + + + + + + + + + + true + + + terms + + + + + + + + string + elevate.xml + + + + + + explicit + + + elevator + + + + + + + + + + + 100 + + + + + + + + 70 + + 0.5 + + [-\w ,/\n\"']{20,200} + + + + + + + ]]> + ]]> + + + + + + + + + + + + + + + + + + + + + ,, + ,, + ,, + ,, + ,]]> + ]]> + + + + + + 10 + .,!? + + + + + + + WORD + + + en + US + + + + + + + + + + + + + + + + + + + text/plain; charset=UTF-8 + + + + + + + + + + 5 + + + + + + + + + + + + + *:* + + + + + + diff --git a/vendor/plugins/acts_as_solr_reloaded/solr/solr/conf/spellings.en.txt b/vendor/plugins/acts_as_solr_reloaded/solr/solr/conf/spellings.en.txt new file mode 100644 index 0000000..44b748d --- /dev/null +++ b/vendor/plugins/acts_as_solr_reloaded/solr/solr/conf/spellings.en.txt @@ -0,0 +1,2 @@ +pizza +history \ No newline at end of file diff --git a/vendor/plugins/acts_as_solr_reloaded/solr/solr/conf/spellings.txt b/vendor/plugins/acts_as_solr_reloaded/solr/solr/conf/spellings.txt deleted file mode 100755 index 44b748d..0000000 --- a/vendor/plugins/acts_as_solr_reloaded/solr/solr/conf/spellings.txt +++ /dev/null @@ -1,2 +0,0 @@ -pizza -history \ No newline at end of file diff --git a/vendor/plugins/acts_as_solr_reloaded/solr/solr/conf/stopwords.en.txt b/vendor/plugins/acts_as_solr_reloaded/solr/solr/conf/stopwords.en.txt new file mode 100644 index 0000000..22f277f --- /dev/null +++ b/vendor/plugins/acts_as_solr_reloaded/solr/solr/conf/stopwords.en.txt @@ -0,0 +1,58 @@ +# Licensed to the Apache Software Foundation (ASF) under one or more +# contributor license agreements. See the NOTICE file distributed with +# this work for additional information regarding copyright ownership. +# The ASF licenses this file to You under the Apache License, Version 2.0 +# (the "License"); you may not use this file except in compliance with +# the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +#----------------------------------------------------------------------- +# a couple of test stopwords to test that the words are really being +# configured from this file: +stopworda +stopwordb + +#Standard english stop words taken from Lucene's StopAnalyzer +a +an +and +are +as +at +be +but +by +for +if +in +into +is +it +no +not +of +on +or +s +such +t +that +the +their +then +there +these +they +this +to +was +will +with + diff --git a/vendor/plugins/acts_as_solr_reloaded/solr/solr/conf/stopwords.pt.txt b/vendor/plugins/acts_as_solr_reloaded/solr/solr/conf/stopwords.pt.txt new file mode 100644 index 0000000..7d752a8 --- /dev/null +++ b/vendor/plugins/acts_as_solr_reloaded/solr/solr/conf/stopwords.pt.txt @@ -0,0 +1,128 @@ +a +ainda +alem +ambas +ambos +antes +ao +aonde +aos +apos +aquele +aqueles +as +assim +com +como +contra +contudo +cuja +cujas +cujo +cujos +da +das +de +dela +dele +deles +demais +depois +desde +desta +deste +dispoe +dispoem +diversa +diversas +diversos +do +dos +durante +e +ela +elas +ele +eles +em +entao +entre +essa +essas +esse +esses +esta +estas +este +estes +ha +isso +isto +logo +mais +mas +mediante +menos +mesma +mesmas +mesmo +mesmos +na +nas +nao +nas +nem +nesse +neste +nos +o +os +ou +outra +outras +outro +outros +pelas +pelas +pelo +pelos +perante +pois +por +porque +portanto +proprio +propios +quais +qual +qualquer +quando +quanto +que +quem +quer +se +seja +sem +sendo +seu +seus +sob +sobre +sua +suas +tal +tambem +teu +teus +toda +todas +todo +todos +tua +tuas +tudo +um +uma +umas +uns diff --git a/vendor/plugins/acts_as_solr_reloaded/solr/solr/conf/stopwords.txt b/vendor/plugins/acts_as_solr_reloaded/solr/solr/conf/stopwords.txt deleted file mode 100755 index 22f277f..0000000 --- a/vendor/plugins/acts_as_solr_reloaded/solr/solr/conf/stopwords.txt +++ /dev/null @@ -1,58 +0,0 @@ -# Licensed to the Apache Software Foundation (ASF) under one or more -# contributor license agreements. See the NOTICE file distributed with -# this work for additional information regarding copyright ownership. -# The ASF licenses this file to You under the Apache License, Version 2.0 -# (the "License"); you may not use this file except in compliance with -# the License. You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. - -#----------------------------------------------------------------------- -# a couple of test stopwords to test that the words are really being -# configured from this file: -stopworda -stopwordb - -#Standard english stop words taken from Lucene's StopAnalyzer -a -an -and -are -as -at -be -but -by -for -if -in -into -is -it -no -not -of -on -or -s -such -t -that -the -their -then -there -these -they -this -to -was -will -with - diff --git a/vendor/plugins/acts_as_solr_reloaded/solr/solr/conf/synonyms.en.txt b/vendor/plugins/acts_as_solr_reloaded/solr/solr/conf/synonyms.en.txt new file mode 100644 index 0000000..453eb31 --- /dev/null +++ b/vendor/plugins/acts_as_solr_reloaded/solr/solr/conf/synonyms.en.txt @@ -0,0 +1,31 @@ +# The ASF licenses this file to You under the Apache License, Version 2.0 +# (the "License"); you may not use this file except in compliance with +# the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +#----------------------------------------------------------------------- +#some test synonym mappings unlikely to appear in real input text +aaa => aaaa +bbb => bbbb1 bbbb2 +ccc => cccc1,cccc2 +a\=>a => b\=>b +a\,a => b\,b +fooaaa,baraaa,bazaaa + +# Some synonym groups specific to this example +GB,gib,gigabyte,gigabytes +MB,mib,megabyte,megabytes +Television, Televisions, TV, TVs +#notice we use "gib" instead of "GiB" so any WordDelimiterFilter coming +#after us won't split it into two words. + +# Synonym mappings can be used for spelling correction too +pixima => pixma + diff --git a/vendor/plugins/acts_as_solr_reloaded/solr/solr/conf/synonyms.txt b/vendor/plugins/acts_as_solr_reloaded/solr/solr/conf/synonyms.txt deleted file mode 100755 index 453eb31..0000000 --- a/vendor/plugins/acts_as_solr_reloaded/solr/solr/conf/synonyms.txt +++ /dev/null @@ -1,31 +0,0 @@ -# The ASF licenses this file to You under the Apache License, Version 2.0 -# (the "License"); you may not use this file except in compliance with -# the License. You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. - -#----------------------------------------------------------------------- -#some test synonym mappings unlikely to appear in real input text -aaa => aaaa -bbb => bbbb1 bbbb2 -ccc => cccc1,cccc2 -a\=>a => b\=>b -a\,a => b\,b -fooaaa,baraaa,bazaaa - -# Some synonym groups specific to this example -GB,gib,gigabyte,gigabytes -MB,mib,megabyte,megabytes -Television, Televisions, TV, TVs -#notice we use "gib" instead of "GiB" so any WordDelimiterFilter coming -#after us won't split it into two words. - -# Synonym mappings can be used for spelling correction too -pixima => pixma - diff --git a/vendor/plugins/acts_as_solr_reloaded/test/functional/acts_as_solr_test.rb b/vendor/plugins/acts_as_solr_reloaded/test/functional/acts_as_solr_test.rb index d84d4c6..f68c424 100644 --- a/vendor/plugins/acts_as_solr_reloaded/test/functional/acts_as_solr_test.rb +++ b/vendor/plugins/acts_as_solr_reloaded/test/functional/acts_as_solr_test.rb @@ -438,16 +438,12 @@ class ActsAsSolrTest < Test::Unit::TestCase end def test_search_given_a_radius - records = Advertise.search "bike", :around => {:latitude => '-39.36', - :longitude => '77.4027', - :radius => 1} + records = Advertise.search "bike", :latitude => '-39.36', :longitude => '77.4027', :radius => 1 assert_equal 0, records.total end def test_records_are_found_in_a_radius - records = Advertise.search "bike", :around => {:latitude => '39.36', - :longitude => '-77.4027', - :radius => 1} + records = Advertise.search "bike", :latitude => '39.36', :longitude => '-77.4027', :radius => 1 assert_equal 1, records.total end diff --git a/vendor/plugins/acts_as_solr_reloaded/test/unit/parser_methods_shoulda.rb b/vendor/plugins/acts_as_solr_reloaded/test/unit/parser_methods_shoulda.rb index e01e3ed..323e0e2 100644 --- a/vendor/plugins/acts_as_solr_reloaded/test/unit/parser_methods_shoulda.rb +++ b/vendor/plugins/acts_as_solr_reloaded/test/unit/parser_methods_shoulda.rb @@ -263,36 +263,28 @@ class ParserMethodsTest < Test::Unit::TestCase ActsAsSolr::Post.expects(:execute).with {|request, core| request.to_hash[:qt] == ('geo') } - @parser.parse_query "foo" , :around => {:latitude => '-39.36', - :longitude => '77.4027', - :radius => 1} + @parser.parse_query "foo" , :latitude => '-39.36', :longitude => '77.4027', :radius => 1 end should "set the radius" do ActsAsSolr::Post.expects(:execute).with {|request, core| request.to_hash[:radius] == 12 } - @parser.parse_query "foo" , :around => {:latitude => '-39.36', - :longitude => '77.4027', - :radius => 12} + @parser.parse_query "foo" , :latitude => '-39.36', :longitude => '77.4027', :radius => 12 end should "set the latitude" do ActsAsSolr::Post.expects(:execute).with {|request, core| request.to_hash[:lat] == '-39.36' } - @parser.parse_query "foo" , :around => {:latitude => '-39.36', - :longitude => '77.4027', - :radius => 12} + @parser.parse_query "foo" , :latitude => '-39.36', :longitude => '77.4027', :radius => 12 end should "set the longitude" do ActsAsSolr::Post.expects(:execute).with {|request, core| request.to_hash[:long] == '77.4027' } - @parser.parse_query "foo" , :around => {:latitude => '-39.36', - :longitude => '77.4027', - :radius => 12} + @parser.parse_query "foo" , :latitude => '-39.36', :longitude => '77.4027', :radius => 12 end end -- libgit2 0.21.2