[options]"
-
- attr_reader :options, :command
-
- def initialize
- @options = {}
- end
-
- def valid_command?
- COMMANDS.include?@command
- end
-
- def valid_options?
- @options[:name] and !@options[:name].empty?
- end
-
- def print_command_list
- puts BANNER
- puts "\nAvailable commands:\n"
- puts COMMANDS.map {|cmd| " - #{cmd}\n"}
- puts "\nUse option -h for each command to help."
- exit
- end
-
- def validate_options
- errors = []
- errors << "Service name is required." unless @options[:name]
-
- if (errors.size > 0)
- errors << "Error found. Use: 'ruby script/ferret_service #{@command} -h' for to get help."
- puts errors.join("\n")
- exit
- end
- end
-
- def run(args)
- @command = args.shift
- @command = @command.dup.downcase if @command
-
- # validate command and options
- print_command_list unless valid_command? or @command == 'help'
-
- opts_parser = create_options_parser
- begin
- opts_parser.parse!(args)
- rescue OptionParser::ParseError => e
- puts e
- puts opts_parser
- end
-
- # validate required options
- validate_options
- end
-
- def create_options_parser
- opts_parser = OptionParser.new
- opts_parser.banner = BANNER
- opts_parser.on("-n", "--name=NAME", "Service name") {|name| @options[:name] = name }
- opts_parser.on_tail("-t", "--trace", "Display stack trace when exception thrown") { @options[:trace] = true }
- opts_parser.on_tail("-h", "--help", "Show this help message") { puts opts_parser; exit }
-
- if ['install'].include?@command
- opts_parser.on("-d", "--display=NAME", "Service display name") {|name| @options[:display] = name }
-
- opts_parser.on("-l", "--log FILE", "Service log file") {|file| @options[:log] = file }
- opts_parser.on("-e", "--environment ENV ", "Rails environment") { |env|
- @options[:environment] = env
- ENV['RAILS_ENV'] = env
- }
- end
- opts_parser
- end
- end
-
- # Install, Remove, Start and Stop Ferret DRb server Win32 service
- class FerretService
- FERRET_DAEMON = 'ferret_daemon'
-
- def initialize
- end
-
- def install
- svc = Service.new
-
- begin
- if Service.exists?(@options[:name])
- puts "Service name '#{@options[:name]}' already exists."
- return
- end
-
- svc.create_service do |s|
- s.service_name = @options[:name]
- s.display_name = @options[:display]
- s.binary_path_name = binary_path_name
- s.dependencies = []
- end
-
- svc.close
- puts "'#{@options[:name]}' service installed."
- rescue => e
- handle_error(e)
- end
- end
-
- def remove
- begin
- Service.stop(@options[:name])
- rescue
- end
-
- begin
- Service.delete(@options[:name])
- puts "'#{@options[:name]}' service removed."
- rescue => e
- handle_error(e)
- end
- end
-
- def start
- begin
- Service.start(@options[:name])
- puts "'#{@options[:name]}' successfully started."
- rescue => e
- handle_error(e)
- end
- end
-
- def stop
- begin
- Service.stop(@options[:name])
- puts "'#{@options[:name]}' successfully stopped.\n"
- rescue => e
- handle_error(e)
- end
- end
-
- def run(args)
- svc_cmd = FerretServiceCommand.new
- svc_cmd.run(args)
- @options = svc_cmd.options
- self.send(svc_cmd.command.to_sym)
- end
-
- protected
- def handle_error(e)
- if @options[:trace]
- raise e
- else
- puts e
- end
- end
-
- def binary_path_name
- path = ""
- path << "#{ENV['RUBY_HOME']}/bin/" if ENV['RUBY_HOME']
- path << "ruby.exe "
- path << File.expand_path("script/" + FERRET_DAEMON)
- path << " -e #{@options[:environment]} " if @options[:environment]
- path << " -l #{@options[:log]} " if @options[:log]
- path
- end
- end
-end
-
-Ferret::FerretService.new.run(ARGV)
diff --git a/vendor/plugins/acts_as_ferret/tasks/ferret.rake b/vendor/plugins/acts_as_ferret/tasks/ferret.rake
deleted file mode 100644
index 7a761aa..0000000
--- a/vendor/plugins/acts_as_ferret/tasks/ferret.rake
+++ /dev/null
@@ -1,24 +0,0 @@
-namespace :ferret do
-
- # Rebuild index task. Declare the indexes to be rebuilt with the INDEXES
- # environment variable:
- #
- # INDEXES="my_model shared" rake ferret:rebuild
- desc "Rebuild a Ferret index. Specify what model to rebuild with the MODEL environment variable."
- task :rebuild do
- require File.join(RAILS_ROOT, 'config', 'environment')
-
- indexes = ENV['INDEXES'].split
- indexes.each do |index_name|
- start = 1.minute.ago
- ActsAsFerret::rebuild_index index_name
- idx = ActsAsFerret::get_index index_name
- # update records that have changed since the rebuild started
- idx.index_definition[:registered_models].each do |m|
- m.records_modified_since(start).each do |object|
- object.ferret_update
- end
- end
- end
- end
-end
diff --git a/vendor/plugins/acts_as_solr_reloaded/.gitignore b/vendor/plugins/acts_as_solr_reloaded/.gitignore
new file mode 100644
index 0000000..c855325
--- /dev/null
+++ b/vendor/plugins/acts_as_solr_reloaded/.gitignore
@@ -0,0 +1,17 @@
+*.log
+*.log
+*_pid
+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
diff --git a/vendor/plugins/acts_as_solr_reloaded/LICENSE b/vendor/plugins/acts_as_solr_reloaded/LICENSE
new file mode 100644
index 0000000..4b2cf05
--- /dev/null
+++ b/vendor/plugins/acts_as_solr_reloaded/LICENSE
@@ -0,0 +1,22 @@
+(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/README.markdown b/vendor/plugins/acts_as_solr_reloaded/README.markdown
new file mode 100644
index 0000000..9d2f240
--- /dev/null
+++ b/vendor/plugins/acts_as_solr_reloaded/README.markdown
@@ -0,0 +1,64 @@
+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.
+It was based on the first draft by Erik Hatcher.
+
+This plugin is intended for use in old versions of Rails. For newer versions, I strongly advice using Sunspot!
+Nevertheless, this plugin is used for Noosfero project in production. Any problem please open an issue.
+
+Installation
+======
+
+Install as a plugin
+
+ script/plugin install git://github.com/brauliobo/acts_as_solr_reloaded.git
+
+Download Solr 3.1
+
+ 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
+
+Configuration
+======
+See config/solr.yml file.
+
+Basic 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
+
+# Please see ActsAsSolr::ActsMethods for a complete info
+
+
+
+
+`acts_as_solr` 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`
+
+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)
+ true
+ end
+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
new file mode 100644
index 0000000..08d77e0
--- /dev/null
+++ b/vendor/plugins/acts_as_solr_reloaded/README.rdoc
@@ -0,0 +1,96 @@
+= 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/Rakefile b/vendor/plugins/acts_as_solr_reloaded/Rakefile
new file mode 100644
index 0000000..18b5a86
--- /dev/null
+++ b/vendor/plugins/acts_as_solr_reloaded/Rakefile
@@ -0,0 +1,71 @@
+require 'rubygems'
+require 'rake'
+require 'rake/testtask'
+require 'rake/rdoctask'
+
+Dir["#{File.dirname(__FILE__)}/lib/tasks/*.rake"].sort.each { |ext| load ext }
+
+desc "Default Task"
+task :default => [:test]
+
+desc "Runs the unit tests"
+task :test => "test:unit"
+
+namespace :test do
+ task :setup do
+ RAILS_ROOT = File.expand_path("#{File.dirname(__FILE__)}/test") unless defined? RAILS_ROOT
+ ENV['RAILS_ENV'] = "test"
+ ENV["ACTS_AS_SOLR_TEST"] = "true"
+ require File.expand_path("#{File.dirname(__FILE__)}/config/solr_environment")
+ puts "Using " + DB
+ %x(mysql -u#{MYSQL_USER} < #{File.dirname(__FILE__) + "/test/fixtures/db_definitions/mysql.sql"}) if DB == 'mysql'
+
+ Rake::Task["test:migrate"].invoke
+ end
+
+ desc 'Measures test coverage using rcov'
+ task :rcov => :setup do
+ rm_f "coverage"
+ rm_f "coverage.data"
+ rcov = "rcov --rails --aggregate coverage.data --text-summary -Ilib"
+
+ system("#{rcov} --html #{Dir.glob('test/**/*_shoulda.rb').join(' ')}")
+ system("open coverage/index.html") if PLATFORM['darwin']
+ end
+
+ desc 'Runs the functional tests, testing integration with Solr'
+ Rake::TestTask.new('functional' => :setup) do |t|
+ t.pattern = "test/functional/*_test.rb"
+ t.verbose = true
+ end
+
+ desc "Unit tests"
+ Rake::TestTask.new(:unit) do |t|
+ t.libs << 'test/unit'
+ t.pattern = "test/unit/*_shoulda.rb"
+ t.verbose = true
+ end
+end
+
+Rake::RDocTask.new do |rd|
+ rd.main = "README.rdoc"
+ rd.rdoc_dir = "rdoc"
+ rd.rdoc_files.exclude("lib/solr/**/*.rb", "lib/solr.rb")
+ rd.rdoc_files.include("README.rdoc", "lib/**/*.rb")
+end
+
+begin
+ require 'jeweler'
+ Jeweler::Tasks.new do |s|
+ s.name = "acts_as_solr_reloaded"
+ s.summary = "This gem adds full text search capabilities and many other nifty features from Apache Solr to any Rails model."
+ s.email = "dc.rec1@gmail.com"
+ s.homepage = "http://github.com/dcrec1/acts_as_solr_reloaded"
+ s.description = "This gem adds full text search capabilities and many other nifty features from Apache Solr to any Rails model."
+ s.authors = ["Diego Carrion"]
+ s.files = FileList["[A-Z]*", "{bin,generators,config,lib,solr}/**/*"] +
+ FileList["test/**/*"].reject {|f| f.include?("test/log")}.reject {|f| f.include?("test/tmp")}
+ end
+rescue LoadError
+ puts "Jeweler, or one of its dependencies, is not available. Install it with: sudo gem install jeweler"
+end
diff --git a/vendor/plugins/acts_as_solr_reloaded/TESTING_THE_PLUGIN b/vendor/plugins/acts_as_solr_reloaded/TESTING_THE_PLUGIN
new file mode 100644
index 0000000..2404a55
--- /dev/null
+++ b/vendor/plugins/acts_as_solr_reloaded/TESTING_THE_PLUGIN
@@ -0,0 +1,25 @@
+acts_as_solr comes with a quick and fast unit test suite, and with a longer-running
+functional test suite, the latter testing the actual integration with Solr.
+
+The unit test suite is written using Shoulda, so make sure you have a recent version
+installed.
+
+Running `rake test` or just `rake` will run both test suites. Use `rake test:unit` to
+just run the unit test suite.
+
+== How to run functional tests for this plugin:
+To run the acts_as_solr's plugin tests run the following steps:
+
+- create a MySQL database called "actsassolr_test" (if you want to use MySQL)
+
+- create a new Rails project, if needed (the plugin can only be tested from within a Rails project); move/checkout acts_as_solr into its vendor/plugins/, as usual
+
+- copy vendor/plugins/acts_as_solr_reloaded/config/solr.yml to config/ (the Rails config folder)
+
+- rake solr:start RAILS_ENV=test
+
+- rake test:functional (Accepts the following arguments: DB=sqlite|mysql and MYSQL_USER=user)
+
+== Troubleshooting:
+If for some reason the tests don't run and you get MySQL errors, make sure you edit the MYSQL_USER entry under
+config/environment.rb. It's recommended to create or use a MySQL user with no password.
diff --git a/vendor/plugins/acts_as_solr_reloaded/VERSION b/vendor/plugins/acts_as_solr_reloaded/VERSION
new file mode 100644
index 0000000..ce6a70b
--- /dev/null
+++ b/vendor/plugins/acts_as_solr_reloaded/VERSION
@@ -0,0 +1 @@
+1.6.0
\ No newline at end of file
diff --git a/vendor/plugins/acts_as_solr_reloaded/acts_as_solr_reloaded.gemspec b/vendor/plugins/acts_as_solr_reloaded/acts_as_solr_reloaded.gemspec
new file mode 100644
index 0000000..45afb41
--- /dev/null
+++ b/vendor/plugins/acts_as_solr_reloaded/acts_as_solr_reloaded.gemspec
@@ -0,0 +1,205 @@
+# Generated by jeweler
+# DO NOT EDIT THIS FILE DIRECTLY
+# Instead, edit Jeweler::Tasks in Rakefile, and run 'rake gemspec'
+# -*- encoding: utf-8 -*-
+
+Gem::Specification.new do |s|
+ s.name = %q{acts_as_solr_reloaded}
+ s.version = "1.6.0"
+
+ s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
+ s.authors = ["Diego Carrion"]
+ s.date = %q{2011-03-20}
+ s.description = %q{This gem adds full text search capabilities and many other nifty features from Apache Solr to any Rails model.}
+ s.email = %q{dc.rec1@gmail.com}
+ s.extra_rdoc_files = [
+ "LICENSE",
+ "README.markdown",
+ "README.rdoc"
+ ]
+ s.files = [
+ "LICENSE",
+ "README.markdown",
+ "README.rdoc",
+ "Rakefile",
+ "TESTING_THE_PLUGIN",
+ "VERSION",
+ "config/solr.yml",
+ "config/solr_environment.rb",
+ "generators/dynamic_attributes_migration/dynamic_attributes_migration_generator.rb",
+ "generators/dynamic_attributes_migration/templates/migration.rb",
+ "generators/local_migration/local_migration_generator.rb",
+ "generators/local_migration/templates/migration.rb",
+ "lib/acts_as_solr.rb",
+ "lib/acts_as_solr/acts_methods.rb",
+ "lib/acts_as_solr/class_methods.rb",
+ "lib/acts_as_solr/common_methods.rb",
+ "lib/acts_as_solr/deprecation.rb",
+ "lib/acts_as_solr/dynamic_attribute.rb",
+ "lib/acts_as_solr/instance_methods.rb",
+ "lib/acts_as_solr/lazy_document.rb",
+ "lib/acts_as_solr/local.rb",
+ "lib/acts_as_solr/mongo_mapper.rb",
+ "lib/acts_as_solr/parser_methods.rb",
+ "lib/acts_as_solr/search_results.rb",
+ "lib/acts_as_solr/solr_fixtures.rb",
+ "lib/acts_as_solr/tasks.rb",
+ "lib/acts_as_solr_reloaded.rb",
+ "lib/solr.rb",
+ "lib/solr/connection.rb",
+ "lib/solr/document.rb",
+ "lib/solr/exception.rb",
+ "lib/solr/field.rb",
+ "lib/solr/importer.rb",
+ "lib/solr/importer/array_mapper.rb",
+ "lib/solr/importer/delimited_file_source.rb",
+ "lib/solr/importer/hpricot_mapper.rb",
+ "lib/solr/importer/mapper.rb",
+ "lib/solr/importer/solr_source.rb",
+ "lib/solr/importer/xpath_mapper.rb",
+ "lib/solr/indexer.rb",
+ "lib/solr/request.rb",
+ "lib/solr/request/add_document.rb",
+ "lib/solr/request/base.rb",
+ "lib/solr/request/commit.rb",
+ "lib/solr/request/delete.rb",
+ "lib/solr/request/dismax.rb",
+ "lib/solr/request/index_info.rb",
+ "lib/solr/request/modify_document.rb",
+ "lib/solr/request/optimize.rb",
+ "lib/solr/request/ping.rb",
+ "lib/solr/request/select.rb",
+ "lib/solr/request/spellcheck.rb",
+ "lib/solr/request/standard.rb",
+ "lib/solr/request/update.rb",
+ "lib/solr/response.rb",
+ "lib/solr/response/add_document.rb",
+ "lib/solr/response/base.rb",
+ "lib/solr/response/commit.rb",
+ "lib/solr/response/delete.rb",
+ "lib/solr/response/dismax.rb",
+ "lib/solr/response/index_info.rb",
+ "lib/solr/response/modify_document.rb",
+ "lib/solr/response/optimize.rb",
+ "lib/solr/response/ping.rb",
+ "lib/solr/response/ruby.rb",
+ "lib/solr/response/select.rb",
+ "lib/solr/response/spellcheck.rb",
+ "lib/solr/response/standard.rb",
+ "lib/solr/response/xml.rb",
+ "lib/solr/solrtasks.rb",
+ "lib/solr/util.rb",
+ "lib/solr/xml.rb",
+ "lib/tasks/database.rake",
+ "lib/tasks/solr.rake",
+ "lib/tasks/test.rake",
+ "test/config/solr.yml",
+ "test/db/connections/mysql/connection.rb",
+ "test/db/connections/sqlite/connection.rb",
+ "test/db/migrate/001_create_books.rb",
+ "test/db/migrate/002_create_movies.rb",
+ "test/db/migrate/003_create_categories.rb",
+ "test/db/migrate/004_create_electronics.rb",
+ "test/db/migrate/005_create_authors.rb",
+ "test/db/migrate/006_create_postings.rb",
+ "test/db/migrate/007_create_posts.rb",
+ "test/db/migrate/008_create_gadgets.rb",
+ "test/db/migrate/009_create_dynamic_attributes.rb",
+ "test/db/migrate/010_create_advertises.rb",
+ "test/db/migrate/011_create_locals.rb",
+ "test/db/test.db",
+ "test/fixtures/advertises.yml",
+ "test/fixtures/authors.yml",
+ "test/fixtures/books.yml",
+ "test/fixtures/categories.yml",
+ "test/fixtures/db_definitions/mysql.sql",
+ "test/fixtures/dynamic_attributes.yml",
+ "test/fixtures/electronics.yml",
+ "test/fixtures/locals.yml",
+ "test/fixtures/movies.yml",
+ "test/fixtures/postings.yml",
+ "test/functional/acts_as_solr_test.rb",
+ "test/functional/association_indexing_test.rb",
+ "test/functional/faceted_search_test.rb",
+ "test/functional/multi_solr_search_test.rb",
+ "test/models/advertise.rb",
+ "test/models/author.rb",
+ "test/models/book.rb",
+ "test/models/category.rb",
+ "test/models/document.rb",
+ "test/models/dynamic_attribute.rb",
+ "test/models/electronic.rb",
+ "test/models/gadget.rb",
+ "test/models/local.rb",
+ "test/models/movie.rb",
+ "test/models/novel.rb",
+ "test/models/post.rb",
+ "test/models/posting.rb",
+ "test/test_helper.rb",
+ "test/unit/acts_methods_shoulda.rb",
+ "test/unit/class_methods_shoulda.rb",
+ "test/unit/common_methods_shoulda.rb",
+ "test/unit/instance_methods_shoulda.rb",
+ "test/unit/lazy_document_shoulda.rb",
+ "test/unit/parser_instance.rb",
+ "test/unit/parser_methods_shoulda.rb",
+ "test/unit/solr_instance.rb",
+ "test/unit/test_helper.rb"
+ ]
+ s.homepage = %q{http://github.com/dcrec1/acts_as_solr_reloaded}
+ s.require_paths = ["lib"]
+ s.rubygems_version = %q{1.5.0}
+ s.summary = %q{This gem adds full text search capabilities and many other nifty features from Apache Solr to any Rails model.}
+ s.test_files = [
+ "test/db/connections/mysql/connection.rb",
+ "test/db/connections/sqlite/connection.rb",
+ "test/db/migrate/001_create_books.rb",
+ "test/db/migrate/002_create_movies.rb",
+ "test/db/migrate/003_create_categories.rb",
+ "test/db/migrate/004_create_electronics.rb",
+ "test/db/migrate/005_create_authors.rb",
+ "test/db/migrate/006_create_postings.rb",
+ "test/db/migrate/007_create_posts.rb",
+ "test/db/migrate/008_create_gadgets.rb",
+ "test/db/migrate/009_create_dynamic_attributes.rb",
+ "test/db/migrate/010_create_advertises.rb",
+ "test/db/migrate/011_create_locals.rb",
+ "test/functional/acts_as_solr_test.rb",
+ "test/functional/association_indexing_test.rb",
+ "test/functional/faceted_search_test.rb",
+ "test/functional/multi_solr_search_test.rb",
+ "test/models/advertise.rb",
+ "test/models/author.rb",
+ "test/models/book.rb",
+ "test/models/category.rb",
+ "test/models/document.rb",
+ "test/models/dynamic_attribute.rb",
+ "test/models/electronic.rb",
+ "test/models/gadget.rb",
+ "test/models/local.rb",
+ "test/models/movie.rb",
+ "test/models/novel.rb",
+ "test/models/post.rb",
+ "test/models/posting.rb",
+ "test/test_helper.rb",
+ "test/unit/acts_methods_shoulda.rb",
+ "test/unit/class_methods_shoulda.rb",
+ "test/unit/common_methods_shoulda.rb",
+ "test/unit/instance_methods_shoulda.rb",
+ "test/unit/lazy_document_shoulda.rb",
+ "test/unit/parser_instance.rb",
+ "test/unit/parser_methods_shoulda.rb",
+ "test/unit/solr_instance.rb",
+ "test/unit/test_helper.rb"
+ ]
+
+ if s.respond_to? :specification_version then
+ s.specification_version = 3
+
+ if Gem::Version.new(Gem::VERSION) >= Gem::Version.new('1.2.0') then
+ else
+ end
+ else
+ end
+end
+
diff --git a/vendor/plugins/acts_as_solr_reloaded/config/solr.yml b/vendor/plugins/acts_as_solr_reloaded/config/solr.yml
new file mode 100644
index 0000000..79779cf
--- /dev/null
+++ b/vendor/plugins/acts_as_solr_reloaded/config/solr.yml
@@ -0,0 +1,14 @@
+# Config file for the acts_as_solr_reloaded 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
+
+production:
+ url: http://127.0.0.1:8983/solr
+ jvm_options: -server -d64 -Xmx1024M -Xms64M
\ No newline at end of file
diff --git a/vendor/plugins/acts_as_solr_reloaded/config/solr_environment.rb b/vendor/plugins/acts_as_solr_reloaded/config/solr_environment.rb
new file mode 100644
index 0000000..b5d729b
--- /dev/null
+++ b/vendor/plugins/acts_as_solr_reloaded/config/solr_environment.rb
@@ -0,0 +1,43 @@
+ENV['RAILS_ENV'] = (ENV['RAILS_ENV'] || 'development').dup
+require "uri"
+require "fileutils"
+require "yaml"
+dir = File.dirname(__FILE__)
+SOLR_PATH = File.expand_path("#{dir}/../solr") unless defined? SOLR_PATH
+
+# RAILS_ROOT isn't defined yet, so figure it out.
+unless defined? RAILS_ROOT
+ RAILS_ROOT = File.expand_path("#{File.dirname(__FILE__)}/../test")
+end
+unless defined? SOLR_LOGS_PATH
+ SOLR_LOGS_PATH = ENV["SOLR_LOGS_PATH"] || "#{RAILS_ROOT}/log"
+end
+unless defined? SOLR_PIDS_PATH
+ SOLR_PIDS_PATH = ENV["SOLR_PIDS_PATH"] || "#{RAILS_ROOT}/tmp/pids"
+end
+unless defined? SOLR_DATA_PATH
+ SOLR_DATA_PATH = ENV["SOLR_DATA_PATH"] || "#{RAILS_ROOT}/solr/#{ENV['RAILS_ENV']}"
+end
+unless defined? SOLR_CONFIG_PATH
+ SOLR_CONFIG_PATH = ENV["SOLR_CONFIG_PATH"] || "#{SOLR_PATH}/solr"
+end
+unless defined? SOLR_PID_FILE
+ SOLR_PID_FILE="#{SOLR_PIDS_PATH}/solr.#{ENV['RAILS_ENV']}.pid"
+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']]
+
+ SOLR_HOST = ENV['HOST'] || URI.parse(config[ENV['RAILS_ENV']]['url']).host
+ SOLR_PORT = ENV['PORT'] || URI.parse(config[ENV['RAILS_ENV']]['url']).port
+end
+
+SOLR_JVM_OPTIONS = config[ENV['RAILS_ENV']]['jvm_options'] unless defined? SOLR_JVM_OPTIONS
+
+if ENV["ACTS_AS_SOLR_TEST"]
+ require "activerecord"
+ DB = (ENV['DB'] ? ENV['DB'] : 'sqlite') unless defined?(DB)
+ MYSQL_USER = (ENV['MYSQL_USER'].nil? ? 'root' : ENV['MYSQL_USER']) unless defined? MYSQL_USER
+ require File.join(File.dirname(File.expand_path(__FILE__)), '..', 'test', 'db', 'connections', DB, 'connection.rb')
+end
diff --git a/vendor/plugins/acts_as_solr_reloaded/generators/dynamic_attributes_migration/dynamic_attributes_migration_generator.rb b/vendor/plugins/acts_as_solr_reloaded/generators/dynamic_attributes_migration/dynamic_attributes_migration_generator.rb
new file mode 100644
index 0000000..1292d0a
--- /dev/null
+++ b/vendor/plugins/acts_as_solr_reloaded/generators/dynamic_attributes_migration/dynamic_attributes_migration_generator.rb
@@ -0,0 +1,7 @@
+class DynamicAttributesMigrationGenerator < Rails::Generator::Base
+ def manifest
+ record do |m|
+ m.migration_template 'migration.rb', 'db/migrate', :migration_file_name => "dynamic_attributes_migration"
+ end
+ end
+end
\ No newline at end of file
diff --git a/vendor/plugins/acts_as_solr_reloaded/generators/dynamic_attributes_migration/templates/migration.rb b/vendor/plugins/acts_as_solr_reloaded/generators/dynamic_attributes_migration/templates/migration.rb
new file mode 100644
index 0000000..ab4a838
--- /dev/null
+++ b/vendor/plugins/acts_as_solr_reloaded/generators/dynamic_attributes_migration/templates/migration.rb
@@ -0,0 +1,17 @@
+class DynamicAttributesMigration < ActiveRecord::Migration
+ def self.up
+ create_table :dynamic_attributes do |t|
+ t.integer :dynamicable_id
+ t.string :dynamicable_type
+ t.string :name
+ t.text :value
+ t.timestamps
+ end
+ add_index :dynamic_attributes, [:dynamicable_id, :dynamicable_type, :name], :unique => true, :name => 'da_pk'
+ end
+
+ def self.down
+ remove_index 'da_pk'
+ drop_table :dynamic_attributes
+ end
+end
diff --git a/vendor/plugins/acts_as_solr_reloaded/generators/local_migration/local_migration_generator.rb b/vendor/plugins/acts_as_solr_reloaded/generators/local_migration/local_migration_generator.rb
new file mode 100644
index 0000000..1458d43
--- /dev/null
+++ b/vendor/plugins/acts_as_solr_reloaded/generators/local_migration/local_migration_generator.rb
@@ -0,0 +1,7 @@
+class LocalMigrationGenerator < Rails::Generator::Base
+ def manifest
+ record do |m|
+ m.migration_template 'migration.rb', 'db/migrate', :migration_file_name => "local_migration"
+ end
+ end
+end
\ No newline at end of file
diff --git a/vendor/plugins/acts_as_solr_reloaded/generators/local_migration/templates/migration.rb b/vendor/plugins/acts_as_solr_reloaded/generators/local_migration/templates/migration.rb
new file mode 100644
index 0000000..66be240
--- /dev/null
+++ b/vendor/plugins/acts_as_solr_reloaded/generators/local_migration/templates/migration.rb
@@ -0,0 +1,16 @@
+class LocalMigration < ActiveRecord::Migration
+ def self.up
+ create_table :locals do |t|
+ t.integer :localizable_id
+ t.string :localizable_type
+ t.string :latitude
+ t.string :longitude
+
+ t.timestamps
+ end
+ end
+
+ def self.down
+ drop_table :locals
+ end
+end
\ No newline at end of file
diff --git a/vendor/plugins/acts_as_solr_reloaded/init.rb b/vendor/plugins/acts_as_solr_reloaded/init.rb
new file mode 100644
index 0000000..fb35c55
--- /dev/null
+++ b/vendor/plugins/acts_as_solr_reloaded/init.rb
@@ -0,0 +1 @@
+require 'acts_as_solr'
\ No newline at end of file
diff --git a/vendor/plugins/acts_as_solr_reloaded/install.rb b/vendor/plugins/acts_as_solr_reloaded/install.rb
new file mode 100644
index 0000000..425a1d2
--- /dev/null
+++ b/vendor/plugins/acts_as_solr_reloaded/install.rb
@@ -0,0 +1,5 @@
+require 'fileutils'
+
+src = File.join(File.dirname(__FILE__), 'config', 'solr.yml')
+target = File.join(File.dirname(__FILE__), '..', '..', '..', 'config', 'solr.yml')
+FileUtils.cp src, target
\ No newline at end of file
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
new file mode 100644
index 0000000..402695f
--- /dev/null
+++ b/vendor/plugins/acts_as_solr_reloaded/lib/acts_as_solr.rb
@@ -0,0 +1,47 @@
+require 'active_record'
+require 'rexml/document'
+require 'net/http'
+require 'yaml'
+require 'time'
+require 'erb'
+require 'rexml/xpath'
+
+require File.dirname(__FILE__) + '/solr'
+require File.dirname(__FILE__) + '/acts_as_solr/acts_methods'
+require File.dirname(__FILE__) + '/acts_as_solr/common_methods'
+require File.dirname(__FILE__) + '/acts_as_solr/parser_methods'
+require File.dirname(__FILE__) + '/acts_as_solr/class_methods'
+require File.dirname(__FILE__) + '/acts_as_solr/dynamic_attribute'
+require File.dirname(__FILE__) + '/acts_as_solr/local'
+require File.dirname(__FILE__) + '/acts_as_solr/instance_methods'
+require File.dirname(__FILE__) + '/acts_as_solr/common_methods'
+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
+ @config ||= YAML::load_file("#{Rails.root}/config/solr.yml")[Rails.env]
+ 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), credentials)
+ connection.send request
+ end
+ end
+ end
+end
+
+# 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
new file mode 100644
index 0000000..25900df
--- /dev/null
+++ b/vendor/plugins/acts_as_solr_reloaded/lib/acts_as_solr/acts_methods.rb
@@ -0,0 +1,373 @@
+module ActsAsSolr #:nodoc:
+
+ module ActsMethods
+
+ # declares a class as solr-searchable
+ #
+ # ==== options:
+ # fields:: This option can be used to specify only the fields you'd
+ # like to index. If not given, all the attributes from the
+ # class will be indexed. You can also use this option to
+ # include methods that should be indexed as fields
+ #
+ # class Movie < ActiveRecord::Base
+ # acts_as_solr :fields => [:name, :description, :current_time]
+ # def current_time
+ # Time.now.to_s
+ # end
+ # end
+ #
+ # Each field passed can also be a hash with the value being a field type
+ #
+ # class Electronic < ActiveRecord::Base
+ # acts_as_solr :fields => [{:price => :range_float}]
+ # def current_time
+ # Time.now
+ # end
+ # end
+ #
+ # The field types accepted are:
+ #
+ # :float:: Index the field value as a float (ie.: 12.87)
+ # :integer:: Index the field value as an integer (ie.: 31)
+ # :boolean:: Index the field value as a boolean (ie.: true/false)
+ # :date:: Index the field value as a date (ie.: Wed Nov 15 23:13:03 PST 2006)
+ # :string:: Index the field value as a text string, not applying the same indexing
+ # filters as a regular text field
+ # :range_integer:: Index the field value for integer range queries (ie.:[5 TO 20])
+ # :range_float:: Index the field value for float range queries (ie.:[14.56 TO 19.99])
+ #
+ # Setting the field type preserves its original type when indexed
+ #
+ # The field may also be passed with a hash value containing options
+ #
+ # class Author < ActiveRecord::Base
+ # acts_as_solr :fields => [{:full_name => {:type => :text, :as => :name}}]
+ # def full_name
+ # self.first_name + ' ' + self.last_name
+ # end
+ # end
+ #
+ # The options accepted are:
+ #
+ # :type:: Index the field using the specified type
+ # :as:: Index the field using the specified field name
+ #
+ # additional_fields:: This option takes fields to be include in the index
+ # in addition to those derived from the database. You
+ # can also use this option to include custom fields
+ # derived from methods you define. This option will be
+ # ignored if the :fields option is given. It also accepts
+ # the same field types as the option above
+ #
+ # class Movie < ActiveRecord::Base
+ # acts_as_solr :additional_fields => [:current_time]
+ # def current_time
+ # Time.now.to_s
+ # end
+ # end
+ #
+ # exclude_fields:: This option taks an array of fields that should be ignored from indexing:
+ #
+ # class User < ActiveRecord::Base
+ # acts_as_solr :exclude_fields => [:password, :login, :credit_card_number]
+ # end
+ #
+ # include:: This option can be used for association indexing, which
+ # means you can include any :has_one, :has_many, :belongs_to
+ # and :has_and_belongs_to_many association to be indexed:
+ #
+ # class Category < ActiveRecord::Base
+ # has_many :books
+ # acts_as_solr :include => [:books]
+ # end
+ #
+ # Each association may also be specified as a hash with an option hash as a value
+ #
+ # class Book < ActiveRecord::Base
+ # belongs_to :author
+ # has_many :distribution_companies
+ # has_many :copyright_dates
+ # has_many :media_types
+ # acts_as_solr(
+ # :fields => [:name, :description],
+ # :include => [
+ # {:author => {:using => :fullname, :as => :name}},
+ # {:media_types => {:using => lambda{|media| type_lookup(media.id)}}}
+ # {:distribution_companies => {:as => :distributor, :multivalued => true}},
+ # {:copyright_dates => {:as => :copyright, :type => :date}}
+ # ]
+ # ]
+ #
+ # The options accepted are:
+ #
+ # :type:: Index the associated objects using the specified type
+ # :as:: Index the associated objects using the specified field name
+ # :using:: Index the associated objects using the value returned by the specified method or proc. If a method
+ # symbol is supplied, it will be sent to each object to look up the value to index; if a proc is
+ # supplied, it will be called once for each object with the object as the only argument
+ # :multivalued:: Index the associated objects using one field for each object rather than joining them
+ # all into a single field
+ #
+ # facets:: This option can be used to specify the fields you'd like to
+ # index as facet fields
+ #
+ # class Electronic < ActiveRecord::Base
+ # acts_as_solr :facets => [:category, :manufacturer]
+ # end
+ #
+ # boost:: You can pass a boost (float) value that will be used to boost the document and/or a field. To specify a more
+ # boost for the document, you can either pass a block or a symbol. The block will be called with the record
+ # as an argument, a symbol will result in the according method being called:
+ #
+ # class Electronic < ActiveRecord::Base
+ # acts_as_solr :fields => [{:price => {:boost => 5.0}}], :boost => 10.0
+ # end
+ #
+ # class Electronic < ActiveRecord::Base
+ # acts_as_solr :fields => [{:price => {:boost => 5.0}}], :boost => proc {|record| record.id + 120*37}
+ # end
+ #
+ # class Electronic < ActiveRecord::Base
+ # acts_as_solr :fields => [{:price => {:boost => :price_rating}}], :boost => 10.0
+ # end
+ #
+ # if:: Only indexes the record if the condition evaluated is true. The argument has to be
+ # either a symbol, string (to be eval'ed), proc/method, or class implementing a static
+ # validation method. It behaves the same way as ActiveRecord's :if option.
+ #
+ # class Electronic < ActiveRecord::Base
+ # acts_as_solr :if => proc{|record| record.is_active?}
+ # end
+ #
+ # offline:: Assumes that your using an outside mechanism to explicitly trigger indexing records, e.g. you only
+ # want to update your index through some asynchronous mechanism. Will accept either a boolean or a block
+ # that will be evaluated before actually contacting the index for saving or destroying a document. Defaults
+ # to false. It doesn't refer to the mechanism of an offline index in general, but just to get a centralized point
+ # where you can control indexing. Note: This is only enabled for saving records. acts_as_solr doesn't always like
+ # it, if you have a different number of results coming from the database and the index. This might be rectified in
+ # another patch to support lazy loading.
+ #
+ # class Electronic < ActiveRecord::Base
+ # acts_as_solr :offline => proc {|record| record.automatic_indexing_disabled?}
+ # end
+ #
+ # auto_commit:: The commit command will be sent to Solr only if its value is set to true:
+ #
+ # class Author < ActiveRecord::Base
+ # acts_as_solr :auto_commit => false
+ # end
+ #
+ # 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)
+
+ extend ClassMethods
+ include InstanceMethods
+ include CommonMethods
+ include ParserMethods
+
+ define_solr_configuration_methods
+
+ acts_as_taggable_on :tags if options[:taggable]
+ has_many :dynamic_attributes, :as => "dynamicable" if options[:dynamic_attributes]
+ has_one :local, :as => "localizable" if options[:spatial]
+
+ after_save :solr_save
+ after_destroy :solr_destroy
+
+ if deferred_solr_configuration
+ self.deferred_solr_configuration = deferred_solr_configuration
+ else
+ process_acts_as_solr(options, solr_options)
+ end
+ end
+
+ def process_acts_as_solr(options, solr_options)
+ process_solr_options(options, solr_options)
+ end
+
+ def define_solr_configuration_methods
+ # I'd like to use cattr_accessor, but it does not support lazy loaders and delegation to the class in the instance methods.
+ # TODO: Reconcile with cattr_accessor, or a more appropriate method.
+ class_eval(<<-EOS, __FILE__, __LINE__)
+ @@configuration = nil unless defined?(@@configuration)
+ @@solr_configuration = nil unless defined?(@@solr_configuration)
+ @@deferred_solr_configuration = nil unless defined?(@@deferred_solr_configuration)
+
+ def self.configuration
+ return @@configuration if @@configuration
+ process_deferred_solr_configuration
+ @@configuration
+ end
+ def configuration
+ self.class.configuration
+ end
+ def self.configuration=(value)
+ @@configuration = value
+ end
+ def configuration=(value)
+ self.class.configuration = value
+ end
+
+ def self.solr_configuration
+ return @@solr_configuration if @@solr_configuration
+ process_deferred_solr_configuration
+ @@solr_configuration
+ end
+ def solr_configuration
+ self.class.solr_configuration
+ end
+ def self.solr_configuration=(value)
+ @@solr_configuration = value
+ end
+ def solr_configuration=(value)
+ self.class.solr_configuration = value
+ end
+
+ def self.deferred_solr_configuration
+ return @@deferred_solr_configuration if @@deferred_solr_configuration
+ @@deferred_solr_configuration
+ end
+ def deferred_solr_configuration
+ self.class.deferred_solr_configuration
+ end
+ def self.deferred_solr_configuration=(value)
+ @@deferred_solr_configuration = value
+ end
+ def deferred_solr_configuration=(value)
+ self.class.deferred_solr_configuration = value
+ end
+ EOS
+ end
+
+ def process_deferred_solr_configuration
+ return unless deferred_solr_configuration
+ options, solr_options = deferred_solr_configuration.call
+ self.deferred_solr_configuration = nil
+ self.process_solr_options(options, solr_options)
+ end
+
+ def process_solr_options(options={}, solr_options={})
+ self.configuration = {
+ :fields => nil,
+ :additional_fields => nil,
+ :dynamic_attributes => false,
+ :exclude_fields => [],
+ :auto_commit => true,
+ :include => nil,
+ :facets => nil,
+ :boost => nil,
+ :if => "true",
+ :offline => false,
+ :spatial => false
+ }
+ self.solr_configuration = {
+ :type_field => "type_s",
+ :primary_key_field => "pk_s",
+ :default_boost => 1.0
+ }
+
+ configuration.update(options) if options.is_a?(Hash)
+ solr_configuration.update(solr_options) if solr_options.is_a?(Hash)
+ Deprecation.validate_index(configuration)
+
+ configuration[:solr_fields] = {}
+ configuration[:solr_includes] = {}
+
+ if configuration[:fields].respond_to?(:each)
+ process_fields(configuration[:fields])
+ else
+ process_fields(self.new.attributes.keys.map { |k| k.to_sym })
+ process_fields(configuration[:additional_fields])
+ end
+
+ if configuration[:include].respond_to?(:each)
+ process_includes(configuration[:include])
+ end
+ end
+
+ private
+
+ def get_field_value(field)
+ 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 = ''
+ end
+ end
+ end
+
+ def process_fields(raw_field)
+ if raw_field.respond_to?(:each)
+ raw_field.each do |field|
+ next if configuration[:exclude_fields].include?(field)
+ get_field_value(field)
+ end
+ end
+ 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
+ end
+ end
+
+ def determine_field_name_and_options(field)
+ if field.is_a?(Hash)
+ name = field.keys.first
+ options = field.values.first
+ if options.is_a?(Hash)
+ [name, {:type => type_for_field(field)}.merge(options)]
+ else
+ [name, {:type => options}]
+ end
+ else
+ [field, {:type => type_for_field(field)}]
+ end
+ end
+
+ def type_for_field(field)
+ if configuration[:facets] && configuration[:facets].include?(field)
+ :facet
+ elsif column = columns_hash[field.to_s]
+ column_type = format_column_type(column.type)
+
+ case column_type
+ when :string then :text
+ when :datetime then :date
+ when :time then :date
+ else column_type
+ end
+ else
+ :text
+ end
+ end
+
+ def format_column_type(type)
+ if type.class.eql? Symbol
+ type
+ else
+ type.to_s.eql?("ObjectId") ? :string : type.to_s.downcase.to_sym
+ end
+ end
+ end
+end
\ No newline at end of file
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
new file mode 100644
index 0000000..b7caccf
--- /dev/null
+++ b/vendor/plugins/acts_as_solr_reloaded/lib/acts_as_solr/class_methods.rb
@@ -0,0 +1,242 @@
+module ActsAsSolr #:nodoc:
+
+ module ClassMethods
+ include CommonMethods
+ include ParserMethods
+
+ # Finds instances of a model. Terms are ANDed by default, can be overwritten
+ # by using OR between terms
+ #
+ # Here's a sample (untested) code for your controller:
+ #
+ # def search
+ # results = Book.find_by_solr params[:query]
+ # end
+ #
+ # You can also search for specific fields by searching for 'field:value'
+ #
+ # ====options:
+ # offset:: - The first document to be retrieved (offset)
+ # page:: - The page to be retrieved
+ # limit:: - The number of rows per page
+ # per_page:: - Alias for limit
+ # order:: - Orders (sort by) the result set using a given criteria:
+ #
+ # Book.find_by_solr 'ruby', :order => 'description asc'
+ #
+ # field_types:: This option is deprecated and will be obsolete by version 1.0.
+ # There's no need to specify the :field_types anymore when doing a
+ # search in a model that specifies a field type for a field. The field
+ # types are automatically traced back when they're included.
+ #
+ # class Electronic < ActiveRecord::Base
+ # acts_as_solr :fields => [{:price => :range_float}]
+ # end
+ #
+ # facets:: This option argument accepts the following arguments:
+ # fields:: The fields to be included in the faceted search (Solr's facet.field)
+ # query:: The queries to be included in the faceted search (Solr's facet.query)
+ # zeros:: Display facets with count of zero. (true|false)
+ # sort:: Sorts the faceted resuls by highest to lowest count. (true|false)
+ # browse:: This is where the 'drill-down' of the facets work. Accepts an array of
+ # fields in the format "facet_field:term"
+ # mincount:: Replacement for zeros (it has been deprecated in Solr). Specifies the
+ # minimum count necessary for a facet field to be returned. (Solr's
+ # facet.mincount) Overrides :zeros if it is specified. Default is 0.
+ #
+ # dates:: Run date faceted queries using the following arguments:
+ # fields:: The fields to be included in the faceted date search (Solr's facet.date).
+ # It may be either a String/Symbol or Hash. If it's a hash the options are the
+ # same as date_facets minus the fields option (i.e., :start:, :end, :gap, :other,
+ # :between). These options if provided will override the base options.
+ # (Solr's f..date.=).
+ # start:: The lower bound for the first date range for all Date Faceting. Required if
+ # :fields is present
+ # end:: The upper bound for the last date range for all Date Faceting. Required if
+ # :fields is prsent
+ # gap:: The size of each date range expressed as an interval to be added to the lower
+ # bound using the DateMathParser syntax. Required if :fields is prsent
+ # hardend:: A Boolean parameter instructing Solr what do do in the event that
+ # facet.date.gap does not divide evenly between facet.date.start and facet.date.end.
+ # other:: This param indicates that in addition to the counts for each date range
+ # constraint between facet.date.start and facet.date.end, other counds should be
+ # calculated. May specify more then one in an Array. The possible options are:
+ # before:: - all records with lower bound less than start
+ # after:: - all records with upper bound greater than end
+ # between:: - all records with field values between start and end
+ # none:: - compute no other bounds (useful in per field assignment)
+ # all:: - shortcut for before, after, and between
+ # filter:: Similar to :query option provided by :facets, in that accepts an array of
+ # of date queries to limit results. Can not be used as a part of a :field hash.
+ # This is the only option that can be used if :fields is not present.
+ #
+ # Example:
+ #
+ # Electronic.find_by_solr "memory", :facets => {:zeros => false, :sort => true,
+ # :query => ["price:[* TO 200]",
+ # "price:[200 TO 500]",
+ # "price:[500 TO *]"],
+ # :fields => [:category, :manufacturer],
+ # :browse => ["category:Memory","manufacturer:Someone"]}
+ #
+ #
+ # Examples of date faceting:
+ #
+ # basic:
+ # Electronic.find_by_solr "memory", :facets => {:dates => {:fields => [:updated_at, :created_at],
+ # :start => 'NOW-10YEARS/DAY', :end => 'NOW/DAY', :gap => '+2YEARS', :other => :before}}
+ #
+ # advanced:
+ # Electronic.find_by_solr "memory", :facets => {:dates => {:fields => [:updated_at,
+ # {:created_at => {:start => 'NOW-20YEARS/DAY', :end => 'NOW-10YEARS/DAY', :other => [:before, :after]}
+ # }], :start => 'NOW-10YEARS/DAY', :end => 'NOW/DAY', :other => :before, :filter =>
+ # ["created_at:[NOW-10YEARS/DAY TO NOW/DAY]", "updated_at:[NOW-1YEAR/DAY TO NOW/DAY]"]}}
+ #
+ # filter only:
+ # Electronic.find_by_solr "memory", :facets => {:dates => {:filter => "updated_at:[NOW-1YEAR/DAY TO NOW/DAY]"}}
+ #
+ #
+ #
+ # scores:: If set to true this will return the score as a 'solr_score' attribute
+ # for each one of the instances found. Does not currently work with find_id_by_solr
+ #
+ # books = Book.find_by_solr 'ruby OR splinter', :scores => true
+ # books.records.first.solr_score
+ # => 1.21321397
+ # books.records.last.solr_score
+ # => 0.12321548
+ #
+ # lazy:: If set to true the search will return objects that will touch the database when you ask for one
+ # of their attributes for the first time. Useful when you're using fragment caching based solely on
+ # types and ids.
+ #
+ # relevance:: Sets fields relevance
+ #
+ # Book.find_by_solr "zidane", :relevance => {:title => 5, :author => 2}
+ #
+ def find_by_solr(query, options={})
+ data = parse_query(query, options)
+ return parse_results(data, options)
+ end
+ alias :search :find_by_solr
+
+ # Finds instances of a model and returns an array with the ids:
+ # Book.find_id_by_solr "rails" => [1,4,7]
+ # The options accepted are the same as find_by_solr
+ #
+ def find_id_by_solr(query, options={})
+ data = parse_query(query, options)
+ return parse_results(data, {:format => :ids})
+ end
+
+ # This method can be used to execute a search across multiple models:
+ # Book.multi_solr_search "Napoleon OR Tom", :models => [Movie]
+ #
+ # ====options:
+ # Accepts the same options as find_by_solr plus:
+ # models:: The additional models you'd like to include in the search
+ # results_format:: Specify the format of the results found
+ # :objects :: Will return an array with the results being objects (default). Example:
+ # Book.multi_solr_search "Napoleon OR Tom", :models => [Movie], :results_format => :objects
+ # :ids :: Will return an array with the ids of each entry found. Example:
+ # Book.multi_solr_search "Napoleon OR Tom", :models => [Movie], :results_format => :ids
+ # => [{"id" => "Movie:1"},{"id" => Book:1}]
+ # Where the value of each array is as Model:instance_id
+ # scores:: If set to true this will return the score as a 'solr_score' attribute
+ # for each one of the instances found. Does not currently work with find_id_by_solr
+ #
+ # books = Book.multi_solr_search 'ruby OR splinter', :scores => true
+ # books.records.first.solr_score
+ # => 1.21321397
+ # books.records.last.solr_score
+ # => 0.12321548
+ #
+ def multi_solr_search(query, options = {})
+ models = multi_model_suffix(options)
+ options.update(:results_format => :objects) unless options[:results_format]
+ data = parse_query(query, options, models)
+
+ if data.nil? or data.total_hits == 0
+ return SearchResults.new(:docs => [], :total => 0)
+ end
+
+ result = find_multi_search_objects(data, options)
+ if options[:scores] and options[:results_format] == :objects
+ add_scores(result, data)
+ end
+ SearchResults.new :docs => result, :total => data.total_hits
+ end
+
+ def find_multi_search_objects(data, options)
+ result = []
+ if options[:results_format] == :objects
+ data.hits.each do |doc|
+ k = doc.fetch('id').first.to_s.split(':')
+ result << k[0].constantize.find_by_id(k[1])
+ end
+ elsif options[:results_format] == :ids
+ data.hits.each{|doc| result << {"id" => doc["id"].to_s}}
+ end
+ result
+ end
+
+ def multi_model_suffix(options)
+ models = "AND (#{solr_configuration[:type_field]}:\"#{self.name}\""
+ models << " OR " + options[:models].collect {|m| "#{solr_configuration[:type_field]}:\"" + m.to_s + "\""}.join(" OR ") if options[:models].is_a?(Array)
+ models << ")"
+ end
+
+ # returns the total number of documents found in the query specified:
+ # Book.count_by_solr 'rails' => 3
+ #
+ def count_by_solr(query, options = {})
+ 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
+ #
+ # If batch_size is greater than 0, adds will be done in batches.
+ # NOTE: If using sqlserver, be sure to use a finder with an explicit order.
+ # Non-edge versions of rails do not handle pagination correctly for sqlserver
+ # without an order clause.
+ #
+ # 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, &finder)
+ finder ||= lambda { |ar, options| ar.find(:all, options.merge({:order => self.primary_key})) }
+ start_time = Time.now
+
+ if batch_size > 0
+ items_processed = 0
+ limit = batch_size
+ offset = 0
+ begin
+ iteration_start = Time.now
+ items = finder.call(self, {:limit => limit, :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
+ 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}"
+ end
+ end
+end
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
new file mode 100644
index 0000000..afd404d
--- /dev/null
+++ b/vendor/plugins/acts_as_solr_reloaded/lib/acts_as_solr/common_methods.rb
@@ -0,0 +1,87 @@
+module ActsAsSolr #:nodoc:
+
+ module CommonMethods
+
+ # Converts field types into Solr types
+ def get_solr_field_type(field_type)
+ if field_type.is_a?(Symbol)
+ case field_type
+ when :float
+ return "f"
+ when :integer
+ return "i"
+ when :boolean
+ return "b"
+ when :string
+ return "s"
+ when :date
+ return "d"
+ when :range_float
+ return "rf"
+ when :range_integer
+ return "ri"
+ when :facet
+ return "facet"
+ when :text
+ return "t"
+ else
+ raise "Unknown field_type symbol: #{field_type}"
+ end
+ elsif field_type.is_a?(String)
+ return field_type
+ else
+ raise "Unknown field_type class: #{field_type.class}: #{field_type}"
+ end
+ end
+
+ # Sets a default value when value being set is nil.
+ def set_value_if_nil(field_type)
+ case field_type
+ when "b", :boolean
+ return "false"
+ when "s", "t", "d", :date, :string, :text
+ return ""
+ when "f", "rf", :float, :range_float
+ return 0.00
+ when "i", "ri", :integer, :range_integer
+ return 0
+ else
+ return ""
+ end
+ end
+
+ # Sends an add command to Solr
+ def solr_add(add_xml)
+ ActsAsSolr::Post.execute(Solr::Request::AddDocument.new(add_xml))
+ end
+
+ # Sends the delete command to Solr
+ def solr_delete(solr_ids)
+ ActsAsSolr::Post.execute(Solr::Request::Delete.new(:id => solr_ids))
+ end
+
+ # Sends the commit command to Solr
+ def solr_commit
+ ActsAsSolr::Post.execute(Solr::Request::Commit.new)
+ end
+
+ # Optimizes the Solr index. Solr says:
+ #
+ # Optimizations can take nearly ten minutes to run.
+ # We are presuming optimizations should be run once following large
+ # batch-like updates to the collection and/or once a day.
+ #
+ # One of the solutions for this would be to create a cron job that
+ # runs every day at midnight and optmizes the index:
+ # 0 0 * * * /your_rails_dir/script/runner -e production "Model.solr_optimize"
+ #
+ def solr_optimize
+ ActsAsSolr::Post.execute(Solr::Request::Optimize.new)
+ end
+
+ # Returns the id for the given instance
+ def record_id(object)
+ eval "object.#{object.class.primary_key}"
+ end
+ end
+end
\ No newline at end of file
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
new file mode 100644
index 0000000..94d2194
--- /dev/null
+++ b/vendor/plugins/acts_as_solr_reloaded/lib/acts_as_solr/deprecation.rb
@@ -0,0 +1,61 @@
+module ActsAsSolr #:nodoc:
+
+ class Post
+ def initialize(body, mode = :search)
+ @body = body
+ @mode = mode
+ puts "The method ActsAsSolr::Post.new(body, mode).execute_post is depracated. " +
+ "Use ActsAsSolr::Post.execute(body, mode) instead!"
+ end
+
+ def execute_post
+ ActsAsSolr::Post.execute(@body, @mode)
+ end
+ end
+
+ module ClassMethods
+ def find_with_facet(query, options={})
+ Deprecation.plog "The method find_with_facet is deprecated. Use find_by_solr instead, passing the " +
+ "arguments the same way you used to do with find_with_facet."
+ find_by_solr(query, options)
+ end
+ end
+
+ class Deprecation
+ # Validates the options passed during query
+ def self.validate_query options={}
+ if options[:field_types]
+ plog "The option :field_types for searching is deprecated. " +
+ "The field types are automatically traced back when you specify a field type in your model."
+ end
+ if options[:sort_by]
+ plog "The option :sort_by is deprecated, use :order instead!"
+ options[:order] ||= options[:sort_by]
+ end
+ if options[:start]
+ plog "The option :start is deprecated, use :offset instead!"
+ options[:offset] ||= options[:start]
+ end
+ if options[:rows]
+ plog "The option :rows is deprecated, use :limit instead!"
+ options[:limit] ||= options[:rows]
+ end
+ end
+
+ # Validates the options passed during indexing
+ def self.validate_index options={}
+ if options[:background]
+ plog "The :background option is being deprecated. There are better and more efficient " +
+ "ways to handle delayed saving of your records."
+ end
+ end
+
+ # This will print the text to stdout and log the text
+ # if rails logger is available
+ def self.plog text
+ puts text
+ RAILS_DEFAULT_LOGGER.warn text if defined? RAILS_DEFAULT_LOGGER
+ end
+ end
+
+end
diff --git a/vendor/plugins/acts_as_solr_reloaded/lib/acts_as_solr/dynamic_attribute.rb b/vendor/plugins/acts_as_solr_reloaded/lib/acts_as_solr/dynamic_attribute.rb
new file mode 100644
index 0000000..29f8d2c
--- /dev/null
+++ b/vendor/plugins/acts_as_solr_reloaded/lib/acts_as_solr/dynamic_attribute.rb
@@ -0,0 +1,3 @@
+class DynamicAttribute < ActiveRecord::Base
+ belongs_to :dynamicable, :polymorphic => true
+end
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
new file mode 100644
index 0000000..31031e8
--- /dev/null
+++ b/vendor/plugins/acts_as_solr_reloaded/lib/acts_as_solr/instance_methods.rb
@@ -0,0 +1,196 @@
+module ActsAsSolr #:nodoc:
+
+ module InstanceMethods
+
+ # Solr id is : to be unique across all models
+ def solr_id
+ "#{self.class.name}:#{record_id(self)}"
+ end
+
+ # saves to the Solr index
+ def solr_save
+ return true if indexing_disabled?
+ if evaluate_condition(:if, self)
+ debug "solr_save: #{self.class.name} : #{record_id(self)}"
+ solr_add to_solr_doc
+ solr_commit if configuration[:auto_commit]
+ true
+ else
+ solr_destroy
+ end
+ end
+
+ def indexing_disabled?
+ evaluate_condition(:offline, self) || !configuration[:if]
+ end
+
+ # remove from index
+ def solr_destroy
+ return true if indexing_disabled?
+ debug "solr_destroy: #{self.class.name} : #{record_id(self)}"
+ solr_delete solr_id
+ solr_commit if configuration[:auto_commit]
+ true
+ end
+
+ # convert instance to Solr document
+ def to_solr_doc
+ debug "to_solr_doc: creating doc for class: #{self.class.name}, id: #{record_id(self)}"
+ doc = Solr::Document.new
+ 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}
+
+ # 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
+
+ value = self.send("#{field_name}_for_solr")
+ value = set_value_if_nil(field_type) if value.to_s == ""
+
+ # add the field to the document, but only if it's not the id field
+ # or the type field (from single table inheritance), since these
+ # fields have already been added above.
+ if field_name.to_s != self.class.primary_key and field_name.to_s != "type"
+ suffix = get_solr_field_type(field_type)
+ # This next line ensures that e.g. nil dates are excluded from the
+ # document, since they choke Solr. Also ignores e.g. empty strings,
+ # but these can't be searched for anyway:
+ # http://www.mail-archive.com/solr-dev@lucene.apache.org/msg05423.html
+ 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)
+ doc << field
+ end
+ end
+ end
+
+ add_dynamic_attributes(doc)
+ add_includes(doc)
+ add_tags(doc)
+ add_space(doc)
+
+ debug doc.to_xml
+ 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)
+ 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)
+ 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)
+ end if configuration[:dynamic_attributes]
+ end
+
+ def add_includes(doc)
+ if configuration[:solr_includes].respond_to?(:each)
+ configuration[:solr_includes].each do |association, options|
+ data = options[:multivalued] ? [] : ""
+ field_name = options[:as] || association.to_s.singularize
+ field_type = get_solr_field_type(options[:type])
+ field_boost = options[:boost] || solr_configuration[:default_boost]
+ 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
+ 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)
+ doc << field
+ end
+ end
+ when :has_one, :belongs_to
+ record = self.send(association)
+ unless record.nil?
+ doc["#{field_name}_#{suffix}"] = include_value(record, options)
+ end
+ end
+ end
+ end
+ end
+
+ def include_value(record, options)
+ if options[:using].is_a? Proc
+ options[:using].call(record)
+ 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(" ")
+ end
+ end
+
+ def validate_boost(boost)
+ boost_value = case boost
+ when Float
+ return solr_configuration[:default_boost] if boost < 0
+ boost
+ when Proc
+ boost.call(self)
+ when Symbol
+ if self.respond_to?(boost)
+ self.send(boost)
+ end
+ end
+
+ boost_value || solr_configuration[:default_boost]
+ end
+
+ def condition_block?(condition)
+ condition.respond_to?("call") && (condition.arity == 1 || condition.arity == -1)
+ end
+
+ def evaluate_condition(which_condition, field)
+ condition = configuration[which_condition]
+ case condition
+ when Symbol
+ field.send(condition)
+ when String
+ eval(condition, binding)
+ when FalseClass, NilClass
+ false
+ when TrueClass
+ true
+ else
+ if condition_block?(condition)
+ condition.call(field)
+ else
+ raise(
+ ArgumentError,
+ "The :#{which_condition} option has to be either a symbol, string (to be eval'ed), proc/method, true/false, or " +
+ "class implementing a static validation method"
+ )
+ end
+ end
+ end
+ end
+end
diff --git a/vendor/plugins/acts_as_solr_reloaded/lib/acts_as_solr/lazy_document.rb b/vendor/plugins/acts_as_solr_reloaded/lib/acts_as_solr/lazy_document.rb
new file mode 100644
index 0000000..8cf8960
--- /dev/null
+++ b/vendor/plugins/acts_as_solr_reloaded/lib/acts_as_solr/lazy_document.rb
@@ -0,0 +1,18 @@
+module ActsAsSolr
+ class LazyDocument
+ attr_reader :id, :clazz
+
+ def initialize(id, clazz)
+ @id = id
+ @clazz = clazz
+ end
+
+ def method_missing(name, *args)
+ unless @__instance
+ @__instance = @clazz.find(@id)
+ end
+
+ @__instance.send(name, *args)
+ end
+ end
+end
\ No newline at end of file
diff --git a/vendor/plugins/acts_as_solr_reloaded/lib/acts_as_solr/local.rb b/vendor/plugins/acts_as_solr_reloaded/lib/acts_as_solr/local.rb
new file mode 100644
index 0000000..618e5bc
--- /dev/null
+++ b/vendor/plugins/acts_as_solr_reloaded/lib/acts_as_solr/local.rb
@@ -0,0 +1,4 @@
+class Local < ActiveRecord::Base
+ belongs_to :localizable, :polymorphic => true
+ validates_presence_of :latitude, :longitude
+end
\ No newline at end of file
diff --git a/vendor/plugins/acts_as_solr_reloaded/lib/acts_as_solr/mongo_mapper.rb b/vendor/plugins/acts_as_solr_reloaded/lib/acts_as_solr/mongo_mapper.rb
new file mode 100644
index 0000000..0015f4b
--- /dev/null
+++ b/vendor/plugins/acts_as_solr_reloaded/lib/acts_as_solr/mongo_mapper.rb
@@ -0,0 +1,27 @@
+module ActsAsSolr
+ module MongoMapper
+ def self.included(clazz)
+ clazz.extend ActsAsSolr::ActsMethods
+ clazz.extend ClassMethods
+ end
+
+ module ClassMethods
+ def columns_hash
+ keys
+ end
+
+ def primary_key
+ 'id'
+ end
+
+ def find(*args)
+ if args.first.instance_of? Array
+ ids = args.first.map { |id| Mongo::ObjectID.from_string(id) }
+ super :all, :conditions => {primary_key => ids}
+ else
+ super *args
+ end
+ end
+ end
+ 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
new file mode 100644
index 0000000..2b25a24
--- /dev/null
+++ b/vendor/plugins/acts_as_solr_reloaded/lib/acts_as_solr/parser_methods.rb
@@ -0,0 +1,260 @@
+module ActsAsSolr #:nodoc:
+ module ParserMethods
+ protected
+
+ # 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, :include, :lazy, :joins, :select, :core,
+ :around, :relevance, :highlight, :page, :per_page]
+ query_options = {}
+ query = sanitize_query(query) if query
+ return nil if (query.nil? || query.strip == '')
+
+
+ raise "Invalid parameters: #{(options.keys - valid_options).join(',')}" unless (options.keys - valid_options).empty?
+ begin
+ Deprecation.validate_query(options)
+ per_page = options[:per_page] || options[:limit] || 30
+ offset = options[:offset] || (((options[:page] || 1).to_i - 1) * per_page)
+ query_options[:rows] = per_page
+ query_options[:start] = offset
+ query_options[:operator] = options[:operator]
+
+ query = add_relevance query, options[:relevance]
+
+ # 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][:sort] = :count if options[:facets][:sort]
+ query_options[:facets][:mincount] = 0
+ query_options[:facets][:mincount] = 1 if options[:facets][:zeros] == false
+ # 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.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 options[:facets][:dates]
+ query_options[:date_facets] = {}
+ # if options[:facets][:dates][:fields] exists then :start, :end, and :gap must be there
+ if options[:facets][:dates][:fields]
+ [:start, :end, :gap].each { |k| raise "#{k} must be present in faceted date query" unless options[:facets][:dates].include?(k) }
+ query_options[:date_facets][:fields] = []
+ options[:facets][:dates][:fields].each { |f|
+ if f.kind_of? Hash
+ key = f.keys[0]
+ query_options[:date_facets][:fields] << {"#{key}_d" => f[key]}
+ validate_date_facet_other_options(f[key][:other]) if f[key][:other]
+ else
+ query_options[:date_facets][:fields] << "#{f}_d"
+ end
+ }
+ end
+
+ query_options[:date_facets][:start] = options[:facets][:dates][:start] if options[:facets][:dates][:start]
+ query_options[:date_facets][:end] = options[:facets][:dates][:end] if options[:facets][:dates][:end]
+ query_options[:date_facets][:gap] = options[:facets][:dates][:gap] if options[:facets][:dates][:gap]
+ query_options[:date_facets][:hardend] = options[:facets][:dates][:hardend] if options[:facets][:dates][:hardend]
+ query_options[:date_facets][:filter] = replace_types([*options[:facets][:dates][:filter]].collect{|k| "#{k.sub!(/ *:(?!\d) */,"_d:")}"}) if options[:facets][:dates][:filter]
+
+ if options[:facets][:dates][:other]
+ validate_date_facet_other_options(options[:facets][:dates][:other])
+ query_options[:date_facets][:other] = options[:facets][:dates][:other]
+ end
+
+ end
+ end
+
+ if models.nil?
+ # TODO: use a filter query for type, allowing Solr to cache it individually
+ models = "AND #{solr_type_condition}"
+ field_list = solr_configuration[:primary_key_field]
+ else
+ field_list = "id"
+ end
+
+ query_options[:field_list] = [field_list, 'score']
+ query = "(#{query.gsub(/ *: */,"_t:")}) #{models}"
+ order = options[:order].split(/\s*,\s*/).collect{|e| e.gsub(/\s+/,'_t ').gsub(/\bscore_t\b/, 'score') }.join(',') if options[:order]
+ query_options[:query] = replace_types([query])[0] # TODO adjust replace_types to work with String or Array
+
+ 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]
+ end
+
+ ActsAsSolr::Post.execute(Solr::Request::Standard.new(query_options), options[:core])
+ rescue
+ raise "There was a problem executing your search\n#{query_options.inspect}\n: #{$!} in #{$!.backtrace.first}"
+ end
+ end
+
+ def solr_type_condition
+ (subclasses || []).inject("(#{solr_configuration[:type_field]}:\"#{self.name}\"") do |condition, subclass|
+ condition << (subclass.name.empty? ? "" : " OR #{solr_configuration[:type_field]}:\"#{subclass.name}\"")
+ end << ')'
+ end
+
+ # Parses the data returned from Solr
+ def parse_results(solr_data, options = {})
+ results = {
+ :docs => [],
+ :total => 0
+ }
+
+ configuration = {
+ :format => :objects
+ }
+ results.update(:spellcheck => solr_data.data['spellcheck']) unless solr_data.nil?
+ results.update(:facets => {'facet_fields' => []}) if options[:facets]
+ unless solr_data.nil? or solr_data.header['params'].nil?
+ header = solr_data.header
+ results.update :rows => header['params']['rows']
+ results.update :start => header['params']['start']
+ end
+ return SearchResults.new(results) if (solr_data.nil? || solr_data.total_hits == 0)
+
+ configuration.update(options) if options.is_a?(Hash)
+
+ ids = solr_data.hits.collect {|doc| doc["#{solr_configuration[:primary_key_field]}"]}.flatten
+
+ result = find_objects(ids, options, configuration)
+
+ add_scores(result, solr_data) if configuration[:format] == :objects && options[:scores]
+
+ highlighted = {}
+ solr_data.highlighting.map do |x,y|
+ e={}
+ y1=y.map{|x1,y1| e[x1.gsub(/_[^_]*/,"")]=y1} unless y.nil?
+ highlighted[x.gsub(/[^:]*:/,"").to_i]=e
+ end unless solr_data.highlighting.nil?
+
+ results.update(:facets => solr_data.data['facet_counts']) if options[:facets]
+ results.update({:docs => result, :total => solr_data.total_hits, :max_score => solr_data.max_score, :query_time => solr_data.data['responseHeader']['QTime']})
+ results.update({:highlights=>highlighted})
+ SearchResults.new(results)
+ end
+
+
+ def find_objects(ids, options, configuration)
+ 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)
+ else
+ ids
+ end
+
+ result
+ end
+
+ # Reorders the instances keeping the order returned from Solr
+ def reorder(things, ids)
+ ordered_things = []
+ ids.each do |id|
+ thing = things.find { |t| t.id.to_s == id.to_s }
+ ordered_things |= [thing] if thing
+ end
+ ordered_things
+ end
+
+ # 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 ? ":" : ""
+ if configuration[:solr_fields]
+ configuration[:solr_fields].each do |name, options|
+ 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) }
+ end
+ end
+ if configuration[:solr_includes]
+ configuration[:solr_includes].each do |association, options|
+ 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) }
+ end
+ end
+ strings
+ end
+
+ # Adds the score to each one of the instances found
+ def add_scores(results, solr_data)
+ with_score = []
+ solr_data.hits.each do |doc|
+ with_score.push([doc["score"],
+ results.find {|record| scorable_record?(record, doc) }])
+ end
+ with_score.each do |score, object|
+ class << object; attr_accessor :solr_score; end
+ object.solr_score = score
+ end
+ end
+
+ def scorable_record?(record, doc)
+ doc_id = doc["#{solr_configuration[:primary_key_field]}"]
+ if doc_id.nil?
+ doc_id = doc["id"]
+ "#{record.class.name}:#{record_id(record)}" == doc_id.first.to_s
+ else
+ record_id(record).to_s == doc_id.to_s
+ end
+ end
+
+ def validate_date_facet_other_options(options)
+ valid_other_options = [:after, :all, :before, :between, :none]
+ options = [options] unless options.kind_of? Array
+ bad_options = options.map {|x| x.to_sym} - valid_other_options
+ raise "Invalid option#{'s' if bad_options.size > 1} for faceted date's other param: #{bad_options.join(', ')}. May only be one of :after, :all, :before, :between, :none" if bad_options.size > 0
+ end
+
+ # Remove all leading ?'s and *'s from query
+ def sanitize_query(query)
+ query.gsub(/\A([\?|\*| ]+)/, '')
+ end
+
+ private
+
+ def add_relevance(query, relevance)
+ return query if relevance.nil?
+ q = if query.include? ':'
+ q = query.split(":").first.split(" ")
+ q.pop
+ return query if q.empty?
+ q.join ' '
+ else
+ query
+ end
+ relevance.each do |attribute, value|
+ query = "#{query} OR #{attribute}:(#{q})^#{value}"
+ end
+ query
+ 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
new file mode 100644
index 0000000..c8220bf
--- /dev/null
+++ b/vendor/plugins/acts_as_solr_reloaded/lib/acts_as_solr/search_results.rb
@@ -0,0 +1,94 @@
+module ActsAsSolr #:nodoc:
+
+ # TODO: Possibly looking into hooking it up with Solr::Response::Standard
+ #
+ # Class that returns the search results with four methods.
+ #
+ # books = Book.find_by_solr 'ruby'
+ #
+ # the above will return a SearchResults class with 4 methods:
+ #
+ # docs|results|records: will return an array of records found
+ #
+ # books.records.empty?
+ # => false
+ #
+ # total|num_found|total_hits: will return the total number of records found
+ #
+ # books.total
+ # => 2
+ #
+ # facets: will return the facets when doing a faceted search
+ #
+ # max_score|highest_score: returns the highest score found
+ #
+ # books.max_score
+ # => 1.3213213
+ #
+ #
+ class SearchResults
+ def initialize(solr_data={})
+ @solr_data = solr_data
+ end
+
+ # Returns an array with the instances. This method
+ # is also aliased as docs and records
+ def results
+ @solr_data[:docs]
+ end
+
+ # Returns the total records found. This method is
+ # also aliased as num_found and total_hits
+ def total
+ @solr_data[:total]
+ end
+
+ # Returns the facets when doing a faceted search
+ def facets
+ @solr_data[:facets]
+ end
+
+ # Returns the highest score found. This method is
+ # also aliased as highest_score
+ def max_score
+ @solr_data[:max_score]
+ end
+
+ def query_time
+ @solr_data[:query_time]
+ end
+
+ # Returns the highlighted fields which one has asked for..
+ def highlights
+ @solr_data[:highlights]
+ end
+
+ # Returns a suggested query
+ def suggest
+ @solr_data[:spellcheck]['suggestions']['collation'].match(/\((.+)\) /)[1]
+ end
+
+ # Returns the number of documents per page
+ def per_page
+ @solr_data[:rows].to_i
+ end
+
+ # Returns the number of pages found
+ def total_pages
+ (total / per_page.to_f).ceil
+ end
+
+ # Returns the current page
+ def current_page
+ (@solr_data[:start].to_i / per_page) + 1
+ end
+
+ alias docs results
+ alias records results
+ alias num_found total
+ alias total_hits total
+ alias highest_score max_score
+ end
+
+end
+
diff --git a/vendor/plugins/acts_as_solr_reloaded/lib/acts_as_solr/solr_fixtures.rb b/vendor/plugins/acts_as_solr_reloaded/lib/acts_as_solr/solr_fixtures.rb
new file mode 100644
index 0000000..c16781e
--- /dev/null
+++ b/vendor/plugins/acts_as_solr_reloaded/lib/acts_as_solr/solr_fixtures.rb
@@ -0,0 +1,13 @@
+module ActsAsSolr
+
+ class SolrFixtures
+ def self.load(table_names)
+ [table_names].flatten.map { |n| n.to_s }.each do |table_name|
+ klass = instance_eval(File.split(table_name.to_s).last.to_s.gsub('_',' ').split(" ").collect{|w| w.capitalize}.to_s.singularize)
+ klass.rebuild_solr_index if klass.respond_to?(:rebuild_solr_index)
+ end
+ ActsAsSolr::Post.execute(Solr::Request::Commit.new)
+ end
+ end
+
+end
\ No newline at end of file
diff --git a/vendor/plugins/acts_as_solr_reloaded/lib/acts_as_solr/tasks.rb b/vendor/plugins/acts_as_solr_reloaded/lib/acts_as_solr/tasks.rb
new file mode 100644
index 0000000..f2a8d0b
--- /dev/null
+++ b/vendor/plugins/acts_as_solr_reloaded/lib/acts_as_solr/tasks.rb
@@ -0,0 +1,10 @@
+dir = File.dirname(__FILE__)
+require 'rubygems'
+require 'rake'
+require 'net/http'
+require 'active_record'
+require File.expand_path("#{dir}/solr_fixtures")
+
+load File.expand_path("#{dir}/tasks/database.rake")
+load File.expand_path("#{dir}/tasks/solr.rake")
+load File.expand_path("#{dir}/tasks/test.rake")
diff --git a/vendor/plugins/acts_as_solr_reloaded/lib/acts_as_solr_reloaded.rb b/vendor/plugins/acts_as_solr_reloaded/lib/acts_as_solr_reloaded.rb
new file mode 100644
index 0000000..fb35c55
--- /dev/null
+++ b/vendor/plugins/acts_as_solr_reloaded/lib/acts_as_solr_reloaded.rb
@@ -0,0 +1 @@
+require 'acts_as_solr'
\ No newline at end of file
diff --git a/vendor/plugins/acts_as_solr_reloaded/lib/solr.rb b/vendor/plugins/acts_as_solr_reloaded/lib/solr.rb
new file mode 100755
index 0000000..efdfee5
--- /dev/null
+++ b/vendor/plugins/acts_as_solr_reloaded/lib/solr.rb
@@ -0,0 +1,26 @@
+# 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.
+
+module Solr; end
+require File.expand_path("#{File.dirname(__FILE__)}/solr/exception")
+require File.expand_path("#{File.dirname(__FILE__)}/solr/request")
+require File.expand_path("#{File.dirname(__FILE__)}/solr/connection")
+require File.expand_path("#{File.dirname(__FILE__)}/solr/response")
+require File.expand_path("#{File.dirname(__FILE__)}/solr/util")
+require File.expand_path("#{File.dirname(__FILE__)}/solr/xml")
+require File.expand_path("#{File.dirname(__FILE__)}/solr/importer")
+require File.expand_path("#{File.dirname(__FILE__)}/solr/indexer")
+require File.expand_path("#{File.dirname(__FILE__)}/solr/xml")
+require File.expand_path("#{File.dirname(__FILE__)}/solr/field")
+require File.expand_path("#{File.dirname(__FILE__)}/solr/request/base")
+require File.expand_path("#{File.dirname(__FILE__)}/solr/document")
+require File.expand_path("#{File.dirname(__FILE__)}/solr/request/update")
diff --git a/vendor/plugins/acts_as_solr_reloaded/lib/solr/connection.rb b/vendor/plugins/acts_as_solr_reloaded/lib/solr/connection.rb
new file mode 100755
index 0000000..1adb92b
--- /dev/null
+++ b/vendor/plugins/acts_as_solr_reloaded/lib/solr/connection.rb
@@ -0,0 +1,180 @@
+# 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: add a convenience method to POST a Solr .xml file, like Solr's example post.sh
+
+class Solr::Connection
+ attr_reader :url, :autocommit, :connection
+
+ # create a connection to a solr instance using the url for the solr
+ # application context:
+ #
+ # conn = Solr::Connection.new("http://example.com:8080/solr")
+ #
+ # if you would prefer to have all adds/updates autocommitted,
+ # use :autocommit => :on
+ #
+ # conn = Solr::Connection.new('http://example.com:8080/solr',
+ # :autocommit => :on)
+
+ def initialize(url="http://localhost:8983/solr", opts={})
+ @url = URI.parse(url)
+ unless @url.kind_of? URI::HTTP
+ raise "invalid http url: #{url}"
+ end
+
+ # TODO: Autocommit seems nice at one level, but it currently is confusing because
+ # only calls to Connection#add/#update/#delete, though a Connection#send(AddDocument.new(...))
+ # does not autocommit. Maybe #send should check for the request types that require a commit and
+ # commit in #send instead of the individual methods?
+ @autocommit = opts[:autocommit] == :on
+
+ # 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]
+ @username = opts[:username] if opts[:username]
+ @password = opts[:password] if opts[:password]
+ end
+
+ # add a document to the index. you can pass in either a hash
+ #
+ # conn.add(:id => 123, :title => 'Tlon, Uqbar, Orbis Tertius')
+ #
+ # or a Solr::Document
+ #
+ # conn.add(Solr::Document.new(:id => 123, :title = 'On Writing')
+ #
+ # true/false will be returned to designate success/failure
+
+ def add(doc)
+ request = Solr::Request::AddDocument.new(doc)
+ response = send(request)
+ commit if @autocommit
+ return response.ok?
+ end
+
+ # update a document in the index (really just an alias to add)
+
+ def update(doc)
+ return add(doc)
+ end
+
+ # performs a standard query and returns a Solr::Response::Standard
+ #
+ # response = conn.query('borges')
+ #
+ # alternative you can pass in a block and iterate over hits
+ #
+ # conn.query('borges') do |hit|
+ # puts hit
+ # end
+ #
+ # options include:
+ #
+ # :sort, :default_field, :rows, :filter_queries, :debug_query,
+ # :explain_other, :facets, :highlighting, :mlt,
+ # :operator => :or / :and
+ # :start => defaults to 0
+ # :field_list => array, defaults to ["*", "score"]
+
+ def query(query, options={}, &action)
+ # TODO: Shouldn't this return an exception if the Solr status is not ok? (rather than true/false).
+ create_and_send_query(Solr::Request::Standard, options.update(:query => query), &action)
+ end
+
+ # performs a dismax search and returns a Solr::Response::Standard
+ #
+ # response = conn.search('borges')
+ #
+ # options are same as query, but also include:
+ #
+ # :tie_breaker, :query_fields, :minimum_match, :phrase_fields,
+ # :phrase_slop, :boost_query, :boost_functions
+
+ def search(query, options={}, &action)
+ create_and_send_query(Solr::Request::Dismax, options.update(:query => query), &action)
+ end
+
+ # sends a commit message to the server
+ def commit(options={})
+ response = send(Solr::Request::Commit.new(options))
+ return response.ok?
+ end
+
+ # sends an optimize message to the server
+ def optimize
+ response = send(Solr::Request::Optimize.new)
+ return response.ok?
+ end
+
+ # pings the connection and returns true/false if it is alive or not
+ def ping
+ begin
+ response = send(Solr::Request::Ping.new)
+ return response.ok?
+ rescue
+ return false
+ end
+ end
+
+ # delete a document from the index using the document id
+ def delete(document_id)
+ response = send(Solr::Request::Delete.new(:id => document_id))
+ commit if @autocommit
+ response.ok?
+ end
+
+ # delete using a query
+ def delete_by_query(query)
+ response = send(Solr::Request::Delete.new(:query => query))
+ commit if @autocommit
+ response.ok?
+ end
+
+ def info
+ send(Solr::Request::IndexInfo.new)
+ end
+
+ # send a given Solr::Request and return a RubyResponse or XmlResponse
+ # depending on the type of request
+ def send(request)
+ data = post(request)
+ Solr::Response::Base.make_response(request, data)
+ end
+
+ # send the http post request to solr; for convenience there are shortcuts
+ # to some requests: add(), query(), commit(), delete() or send()
+ def post(request)
+ req = Net::HTTP::Post.new(@url.path + "/" + request.handler,
+ { "Content-Type" => request.content_type })
+ req.basic_auth(@username, @password) if @username && @password
+ response = @connection.request(req, request.to_s)
+
+ case response
+ when Net::HTTPSuccess then response.body
+ else
+ response.error!
+ end
+
+ end
+
+private
+
+ def create_and_send_query(klass, options = {}, &action)
+ request = klass.new(options)
+ response = send(request)
+ return response unless action
+ response.each {|hit| action.call(hit)}
+ end
+
+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
new file mode 100644
index 0000000..3c91f4e
--- /dev/null
+++ b/vendor/plugins/acts_as_solr_reloaded/lib/solr/document.rb
@@ -0,0 +1,75 @@
+# 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.
+
+class Solr::Document
+ include Enumerable
+ attr_accessor :boost
+ attr_reader :fields
+
+ # 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')
+ def initialize(hash={})
+ @fields = []
+ self << hash
+ end
+
+ # Append a Solr::Field
+ #
+ # doc << Solr::Field.new(:creator => 'Jorge Luis Borges')
+ #
+ # If you are truly lazy you can simply pass in a hash:
+ #
+ # doc << {:creator => '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)}
+ else
+ @fields << Solr::Field.new(name => value)
+ end
+ end
+ when Solr::Field
+ @fields << fields
+ else
+ raise "must pass in Solr::Field or Hash"
+ end
+ end
+
+ # shorthand to allow hash lookups
+ # doc['name']
+ def [](name)
+ field = @fields.find {|f| f.name == name.to_s}
+ return field.value if field
+ return nil
+ end
+
+ # shorthand to assign as a hash
+ def []=(name,value)
+ @fields << Solr::Field.new(name => value)
+ 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
+ @fields.each {|f| e.add_element(f.to_xml)}
+ return e
+ end
+
+ def each(*args, &blk)
+ fields.each(&blk)
+ end
+end
diff --git a/vendor/plugins/acts_as_solr_reloaded/lib/solr/exception.rb b/vendor/plugins/acts_as_solr_reloaded/lib/solr/exception.rb
new file mode 100644
index 0000000..a439e67
--- /dev/null
+++ b/vendor/plugins/acts_as_solr_reloaded/lib/solr/exception.rb
@@ -0,0 +1,13 @@
+# 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.
+
+class Solr::Exception < Exception; end
diff --git a/vendor/plugins/acts_as_solr_reloaded/lib/solr/field.rb b/vendor/plugins/acts_as_solr_reloaded/lib/solr/field.rb
new file mode 100644
index 0000000..f7bc8dd
--- /dev/null
+++ b/vendor/plugins/acts_as_solr_reloaded/lib/solr/field.rb
@@ -0,0 +1,36 @@
+# 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.
+
+class Solr::Field
+ VALID_PARAMS = [:boost]
+ attr_accessor :name
+ attr_accessor :value
+ attr_accessor :boost
+
+ # 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]
+ # Convert any Time values into UTC/XML schema format (which Solr requires).
+ @value = @value.respond_to?(:utc) ? @value.utc.xmlschema : @value.to_str
+ 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
+ return e
+ end
+
+end
diff --git a/vendor/plugins/acts_as_solr_reloaded/lib/solr/importer.rb b/vendor/plugins/acts_as_solr_reloaded/lib/solr/importer.rb
new file mode 100755
index 0000000..a2cfce9
--- /dev/null
+++ b/vendor/plugins/acts_as_solr_reloaded/lib/solr/importer.rb
@@ -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.
+
+module Solr; module Importer; end; end
+require File.expand_path("#{File.dirname(__FILE__)}/importer/mapper")
+require File.expand_path("#{File.dirname(__FILE__)}/importer/array_mapper")
+require File.expand_path("#{File.dirname(__FILE__)}/importer/delimited_file_source")
+require File.expand_path("#{File.dirname(__FILE__)}/importer/hpricot_mapper")
+require File.expand_path("#{File.dirname(__FILE__)}/importer/xpath_mapper")
+require File.expand_path("#{File.dirname(__FILE__)}/importer/solr_source")
\ No newline at end of file
diff --git a/vendor/plugins/acts_as_solr_reloaded/lib/solr/importer/array_mapper.rb b/vendor/plugins/acts_as_solr_reloaded/lib/solr/importer/array_mapper.rb
new file mode 100755
index 0000000..abef907
--- /dev/null
+++ b/vendor/plugins/acts_as_solr_reloaded/lib/solr/importer/array_mapper.rb
@@ -0,0 +1,26 @@
+# 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.
+
+
+
+class Solr::Importer::ArrayMapper < Solr::Importer::Mapper
+ # TODO document that initializer takes an array of Mappers [mapper1, mapper2, ... mapperN]
+
+ # TODO: make merge conflict handling configurable. as is, the last map fields win.
+ def map(orig_data_array)
+ mapped_data = {}
+ orig_data_array.each_with_index do |data,i|
+ mapped_data.merge!(@mapping[i].map(data))
+ end
+ mapped_data
+ end
+end
\ No newline at end of file
diff --git a/vendor/plugins/acts_as_solr_reloaded/lib/solr/importer/delimited_file_source.rb b/vendor/plugins/acts_as_solr_reloaded/lib/solr/importer/delimited_file_source.rb
new file mode 100755
index 0000000..70f226a
--- /dev/null
+++ b/vendor/plugins/acts_as_solr_reloaded/lib/solr/importer/delimited_file_source.rb
@@ -0,0 +1,38 @@
+# 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.
+
+# For files with the first line containing field names
+# Currently not designed for enormous files, as all lines are
+# read into an array
+class Solr::Importer::DelimitedFileSource
+ include Enumerable
+
+ def initialize(filename, splitter=/\t/)
+ @filename = filename
+ @splitter = splitter
+ end
+
+ def each
+ lines = IO.readlines(@filename)
+ headers = lines[0].split(@splitter).collect{|h| h.chomp}
+
+ lines[1..-1].each do |line|
+ data = headers.zip(line.split(@splitter).collect{|s| s.chomp})
+ def data.[](key)
+ self.assoc(key.to_s)[1]
+ end
+
+ yield(data)
+ end
+ end
+
+end
diff --git a/vendor/plugins/acts_as_solr_reloaded/lib/solr/importer/hpricot_mapper.rb b/vendor/plugins/acts_as_solr_reloaded/lib/solr/importer/hpricot_mapper.rb
new file mode 100644
index 0000000..53a48e4
--- /dev/null
+++ b/vendor/plugins/acts_as_solr_reloaded/lib/solr/importer/hpricot_mapper.rb
@@ -0,0 +1,27 @@
+# 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.
+
+begin
+ require 'hpricot'
+
+ class Solr::Importer::HpricotMapper < Solr::Importer::Mapper
+ def field_data(doc, path)
+ doc.search(path.to_s).collect { |e| e.inner_html }
+ end
+ end
+rescue LoadError => e # If we can't load hpricot
+ class Solr::Importer::HpricotMapper
+ def initialize(mapping, options={})
+ raise "Hpricot not installed."
+ end
+ end
+end
\ No newline at end of file
diff --git a/vendor/plugins/acts_as_solr_reloaded/lib/solr/importer/mapper.rb b/vendor/plugins/acts_as_solr_reloaded/lib/solr/importer/mapper.rb
new file mode 100755
index 0000000..55b199f
--- /dev/null
+++ b/vendor/plugins/acts_as_solr_reloaded/lib/solr/importer/mapper.rb
@@ -0,0 +1,51 @@
+# 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.
+
+class Solr::Importer::Mapper
+ def initialize(mapping, options={})
+ @mapping = mapping
+ @options = options
+ end
+
+ def field_data(orig_data, field_name)
+ orig_data[field_name]
+ end
+
+ def mapped_field_value(orig_data, field_mapping)
+ case field_mapping
+ when String
+ field_mapping
+ when Proc
+ field_mapping.call(orig_data) # TODO pass in more context, like self or a function for field_data, etc
+ when Symbol
+ field_data(orig_data, @options[:stringify_symbols] ? field_mapping.to_s : field_mapping)
+ when Enumerable
+ field_mapping.collect {|orig_field_name| mapped_field_value(orig_data, orig_field_name)}.flatten
+ else
+ raise "Unknown mapping for #{field_mapping}"
+ end
+ end
+
+ def map(orig_data)
+ mapped_data = {}
+ @mapping.each do |solr_name, field_mapping|
+ value = mapped_field_value(orig_data, field_mapping)
+ mapped_data[solr_name] = value if value
+ end
+
+ mapped_data
+ end
+
+
+
+
+end
diff --git a/vendor/plugins/acts_as_solr_reloaded/lib/solr/importer/solr_source.rb b/vendor/plugins/acts_as_solr_reloaded/lib/solr/importer/solr_source.rb
new file mode 100755
index 0000000..d8d57e5
--- /dev/null
+++ b/vendor/plugins/acts_as_solr_reloaded/lib/solr/importer/solr_source.rb
@@ -0,0 +1,41 @@
+# 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.
+
+class Solr::Importer::SolrSource
+ def initialize(solr_url, query, filter_queries=nil, options={})
+ @connection = Solr::Connection.new(solr_url)
+ @query = query
+ @filter_queries = filter_queries
+
+ @page_size = options[:page_size] || 1000
+ @field_list = options[:field_list] || ["*"]
+ end
+
+ def each
+ done = false
+ start = 0
+ until done do
+ # request N documents from a starting point
+ request = Solr::Request::Standard.new(:query => @query,
+ :rows => @page_size,
+ :start => start,
+ :field_list => @field_list,
+ :filter_queries => @filter_queries)
+ response = @connection.send(request)
+ response.each do |doc|
+ yield doc # TODO: perhaps convert to HashWithIndifferentAccess.new(doc), so stringify_keys isn't necessary
+ end
+ done = start + @page_size >= response.total_hits
+ start = start + @page_size
+ end
+ end
+end
diff --git a/vendor/plugins/acts_as_solr_reloaded/lib/solr/importer/xpath_mapper.rb b/vendor/plugins/acts_as_solr_reloaded/lib/solr/importer/xpath_mapper.rb
new file mode 100755
index 0000000..772e1c3
--- /dev/null
+++ b/vendor/plugins/acts_as_solr_reloaded/lib/solr/importer/xpath_mapper.rb
@@ -0,0 +1,35 @@
+# 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.
+
+begin
+ require 'xml/libxml'
+
+ # For files with the first line containing field names
+ class Solr::Importer::XPathMapper < Solr::Importer::Mapper
+ def field_data(doc, xpath)
+ doc.find(xpath.to_s).collect do |node|
+ case node
+ when XML::Attr
+ node.value
+ when XML::Node
+ node.content
+ end
+ end
+ end
+ end
+rescue LoadError => e # If we can't load libxml
+ class Solr::Importer::XPathMapper
+ def initialize(mapping, options={})
+ raise "libxml not installed"
+ end
+ end
+end
diff --git a/vendor/plugins/acts_as_solr_reloaded/lib/solr/indexer.rb b/vendor/plugins/acts_as_solr_reloaded/lib/solr/indexer.rb
new file mode 100755
index 0000000..5210f05
--- /dev/null
+++ b/vendor/plugins/acts_as_solr_reloaded/lib/solr/indexer.rb
@@ -0,0 +1,52 @@
+# 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.
+
+class Solr::Indexer
+ attr_reader :solr
+
+ # TODO: document options!
+ def initialize(data_source, mapper_or_mapping, options={})
+ solr_url = options[:solr_url] || ENV["SOLR_URL"] || "http://localhost:8983/solr"
+ @solr = Solr::Connection.new(solr_url, options) #TODO - these options contain the solr_url and debug keys also, so tidy up what gets passed
+
+ @data_source = data_source
+ @mapper = mapper_or_mapping.is_a?(Hash) ? Solr::Importer::Mapper.new(mapper_or_mapping) : mapper_or_mapping
+
+ @buffer_docs = options[:buffer_docs]
+ @debug = options[:debug]
+ end
+
+ def index
+ buffer = []
+ @data_source.each do |record|
+ document = @mapper.map(record)
+
+ # TODO: check arrity of block, if 3, pass counter as 3rd argument
+ yield(record, document) if block_given? # TODO check return of block, if not true then don't index, or perhaps if document.empty?
+
+ buffer << document
+
+ if !@buffer_docs || buffer.size == @buffer_docs
+ add_docs(buffer)
+ buffer.clear
+ end
+ end
+ add_docs(buffer) if !buffer.empty?
+
+ @solr.commit unless @debug
+ end
+
+ def add_docs(documents)
+ @solr.add(documents) unless @debug
+ puts documents.inspect if @debug
+ end
+end
diff --git a/vendor/plugins/acts_as_solr_reloaded/lib/solr/request.rb b/vendor/plugins/acts_as_solr_reloaded/lib/solr/request.rb
new file mode 100755
index 0000000..b568695
--- /dev/null
+++ b/vendor/plugins/acts_as_solr_reloaded/lib/solr/request.rb
@@ -0,0 +1,26 @@
+# 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.
+
+module Solr; module Request; end; end
+require File.expand_path("#{File.dirname(__FILE__)}/request/base")
+require File.expand_path("#{File.dirname(__FILE__)}/request/update")
+require File.expand_path("#{File.dirname(__FILE__)}/request/add_document")
+require File.expand_path("#{File.dirname(__FILE__)}/request/modify_document")
+require File.expand_path("#{File.dirname(__FILE__)}/request/commit")
+require File.expand_path("#{File.dirname(__FILE__)}/request/delete")
+require File.expand_path("#{File.dirname(__FILE__)}/request/ping")
+require File.expand_path("#{File.dirname(__FILE__)}/request/select")
+require File.expand_path("#{File.dirname(__FILE__)}/request/standard")
+require File.expand_path("#{File.dirname(__FILE__)}/request/spellcheck")
+require File.expand_path("#{File.dirname(__FILE__)}/request/dismax")
+require File.expand_path("#{File.dirname(__FILE__)}/request/index_info")
+require File.expand_path("#{File.dirname(__FILE__)}/request/optimize")
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
new file mode 100644
index 0000000..699d2dd
--- /dev/null
+++ b/vendor/plugins/acts_as_solr_reloaded/lib/solr/request/add_document.rb
@@ -0,0 +1,58 @@
+# 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.
+
+class Solr::Request::AddDocument < Solr::Request::Update
+
+ # create the request, optionally passing in a Solr::Document
+ #
+ # 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'
+ #
+ # or an array, to add multiple documents at the same time:
+ #
+ # request = Solr::Request::AddDocument.new([doc1, doc2, doc3])
+
+ def initialize(doc={})
+ @docs = []
+ if doc.is_a?(Array)
+ doc.each { |d| add_doc(d) }
+ else
+ add_doc(doc)
+ end
+ end
+
+ # returns the request as a string suitable for posting
+
+ def to_s
+ e = Solr::XML::Element.new 'add'
+ for doc in @docs
+ e.add_element doc.to_xml
+ end
+ return e.to_s
+ end
+
+ private
+ def add_doc(doc)
+ case doc
+ when Hash
+ @docs << Solr::Document.new(doc)
+ when Solr::Document
+ @docs << doc
+ else
+ raise "must pass in Solr::Document or Hash"
+ end
+ end
+
+end
diff --git a/vendor/plugins/acts_as_solr_reloaded/lib/solr/request/base.rb b/vendor/plugins/acts_as_solr_reloaded/lib/solr/request/base.rb
new file mode 100644
index 0000000..4b65b1f
--- /dev/null
+++ b/vendor/plugins/acts_as_solr_reloaded/lib/solr/request/base.rb
@@ -0,0 +1,36 @@
+# 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.
+
+class Solr::Request::Base
+
+
+ #TODO : Add base support for the debugQuery flag, and such that the response provides debug output easily
+
+ # returns either :xml or :ruby depending on what the
+ # response type is for a given request
+
+ def response_format
+ raise "unknown request type: #{self.class}"
+ end
+
+ def content_type
+ 'text/xml; charset=utf-8'
+ end
+
+ # returns the solr handler or url fragment that can
+ # respond to this type of request
+
+ def handler
+ raise "unknown request type: #{self.class}"
+ end
+
+end
diff --git a/vendor/plugins/acts_as_solr_reloaded/lib/solr/request/commit.rb b/vendor/plugins/acts_as_solr_reloaded/lib/solr/request/commit.rb
new file mode 100644
index 0000000..30c43fe
--- /dev/null
+++ b/vendor/plugins/acts_as_solr_reloaded/lib/solr/request/commit.rb
@@ -0,0 +1,29 @@
+# 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.
+
+class Solr::Request::Commit < Solr::Request::Update
+
+ def initialize(options={})
+ @wait_searcher = options[:wait_searcher] || true
+ @wait_flush = options[:wait_flush] || true
+ end
+
+
+ def to_s
+ e = Solr::XML::Element.new('commit')
+ e.attributes['waitSearcher'] = @wait_searcher ? 'true' : 'false'
+ e.attributes['waitFlush'] = @wait_flush ? 'true' : 'false'
+
+ e.to_s
+ end
+
+end
diff --git a/vendor/plugins/acts_as_solr_reloaded/lib/solr/request/delete.rb b/vendor/plugins/acts_as_solr_reloaded/lib/solr/request/delete.rb
new file mode 100644
index 0000000..92f9067
--- /dev/null
+++ b/vendor/plugins/acts_as_solr_reloaded/lib/solr/request/delete.rb
@@ -0,0 +1,48 @@
+# 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.
+
+class Solr::Request::Delete < Solr::Request::Update
+
+ # A delete request can be for a specific document id
+ #
+ # request = Solr::Request::Delete.new(:id => 1234)
+ #
+ # or by query:
+ #
+ # request = Solr::Request::Delete.new(:query =>
+ #
+ def initialize(options)
+ unless options.kind_of?(Hash) and (options[:id] or options[:query])
+ raise Solr::Exception.new("must pass in :id or :query")
+ end
+ if options[:id] and options[:query]
+ raise Solr::Exception.new("can't pass in both :id and :query")
+ end
+ @document_id = options[:id]
+ @query = options[:query]
+ end
+
+ def to_s
+ delete_element = Solr::XML::Element.new('delete')
+ if @document_id
+ id_element = Solr::XML::Element.new('id')
+ id_element.text = @document_id
+ delete_element.add_element(id_element)
+ elsif @query
+ query = Solr::XML::Element.new('query')
+ query.text = @query
+ delete_element.add_element(query)
+ end
+ delete_element.to_s
+ end
+end
+
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
new file mode 100644
index 0000000..13d1977
--- /dev/null
+++ b/vendor/plugins/acts_as_solr_reloaded/lib/solr/request/dismax.rb
@@ -0,0 +1,46 @@
+# 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.
+
+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])
+
+ def initialize(params)
+ @alternate_query = params.delete(:alternate_query)
+ @sort_values = params.delete(:sort)
+
+ super
+
+ @query_type = "dismax"
+ end
+
+ def to_hash
+ hash = super
+ 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
+ return hash
+ end
+
+end
\ No newline at end of file
diff --git a/vendor/plugins/acts_as_solr_reloaded/lib/solr/request/index_info.rb b/vendor/plugins/acts_as_solr_reloaded/lib/solr/request/index_info.rb
new file mode 100755
index 0000000..d4eeea5
--- /dev/null
+++ b/vendor/plugins/acts_as_solr_reloaded/lib/solr/request/index_info.rb
@@ -0,0 +1,22 @@
+# 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.
+
+class Solr::Request::IndexInfo < Solr::Request::Select
+
+ def handler
+ 'admin/luke'
+ end
+
+ def to_hash
+ {:numTerms => 0}.merge(super.to_hash)
+ end
+end
diff --git a/vendor/plugins/acts_as_solr_reloaded/lib/solr/request/modify_document.rb b/vendor/plugins/acts_as_solr_reloaded/lib/solr/request/modify_document.rb
new file mode 100644
index 0000000..56e2958
--- /dev/null
+++ b/vendor/plugins/acts_as_solr_reloaded/lib/solr/request/modify_document.rb
@@ -0,0 +1,46 @@
+# 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.
+
+class Solr::Request::ModifyDocument < Solr::Request::Update
+
+ # Example: ModifyDocument.new(:id => 10, :overwrite => {:field_name => "new value"})
+ def initialize(update_data)
+ modes = []
+ @doc = {}
+ [:overwrite, :append, :distinct, :increment, :delete].each do |mode|
+ field_data = update_data[mode]
+ if field_data
+ field_data.each do |field_name, field_value|
+ modes << "#{field_name}:#{mode.to_s.upcase}"
+ @doc[field_name] = field_value if field_value # if value is nil, omit so it can be removed
+ end
+ update_data.delete mode
+ end
+ end
+ @mode = modes.join(",")
+
+ # only one key should be left over, the id
+ @doc[update_data.keys[0].to_s] = update_data.values[0]
+ end
+
+ # returns the request as a string suitable for posting
+ def to_s
+ e = Solr::XML::Element.new 'add'
+ e.add_element(Solr::Document.new(@doc).to_xml)
+ return e.to_s
+ end
+
+ def handler
+ "update?mode=#{@mode}"
+ end
+
+end
diff --git a/vendor/plugins/acts_as_solr_reloaded/lib/solr/request/optimize.rb b/vendor/plugins/acts_as_solr_reloaded/lib/solr/request/optimize.rb
new file mode 100755
index 0000000..c6c9b45
--- /dev/null
+++ b/vendor/plugins/acts_as_solr_reloaded/lib/solr/request/optimize.rb
@@ -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.
+
+class Solr::Request::Optimize < Solr::Request::Update
+
+ def to_s
+ Solr::XML::Element.new('optimize').to_s
+ end
+
+end
\ No newline at end of file
diff --git a/vendor/plugins/acts_as_solr_reloaded/lib/solr/request/ping.rb b/vendor/plugins/acts_as_solr_reloaded/lib/solr/request/ping.rb
new file mode 100644
index 0000000..6b420be
--- /dev/null
+++ b/vendor/plugins/acts_as_solr_reloaded/lib/solr/request/ping.rb
@@ -0,0 +1,36 @@
+# 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: Consider something lazy like this?
+# Solr::Request::Ping = Solr::Request.simple_request :format=>:xml, :handler=>'admin/ping'
+# class Solr::Request
+# def self.simple_request(options)
+# Class.new do
+# def response_format
+# options[:format]
+# end
+# def handler
+# options[:handler]
+# end
+# end
+# end
+# end
+
+class Solr::Request::Ping < Solr::Request::Base
+ def response_format
+ :xml
+ end
+
+ def handler
+ 'admin/ping'
+ end
+end
diff --git a/vendor/plugins/acts_as_solr_reloaded/lib/solr/request/select.rb b/vendor/plugins/acts_as_solr_reloaded/lib/solr/request/select.rb
new file mode 100644
index 0000000..c3595cc
--- /dev/null
+++ b/vendor/plugins/acts_as_solr_reloaded/lib/solr/request/select.rb
@@ -0,0 +1,54 @@
+# 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.
+
+# "Abstract" base class, only useful with subclasses that add parameters
+class Solr::Request::Select < Solr::Request::Base
+
+ attr_reader :query_type
+
+ def initialize(qt=nil, params={})
+ @query_type = qt
+ @select_params = params
+ end
+
+ def response_format
+ :ruby
+ end
+
+ def handler
+ 'select'
+ end
+
+ def content_type
+ 'application/x-www-form-urlencoded; charset=utf-8'
+ end
+
+ def to_hash
+ return {:qt => query_type, :wt => 'ruby'}.merge(@select_params)
+ end
+
+ def to_s
+ raw_params = self.to_hash
+
+ http_params = []
+ raw_params.each do |key,value|
+ if value.respond_to? :each
+ value.each { |v| http_params << "#{key}=#{ERB::Util::url_encode(v)}" unless v.nil?}
+ else
+ http_params << "#{key}=#{ERB::Util::url_encode(value)}" unless value.nil?
+ end
+ end
+
+ http_params.join("&")
+ end
+
+end
diff --git a/vendor/plugins/acts_as_solr_reloaded/lib/solr/request/spellcheck.rb b/vendor/plugins/acts_as_solr_reloaded/lib/solr/request/spellcheck.rb
new file mode 100644
index 0000000..eab24eb
--- /dev/null
+++ b/vendor/plugins/acts_as_solr_reloaded/lib/solr/request/spellcheck.rb
@@ -0,0 +1,30 @@
+# 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.
+
+class Solr::Request::Spellcheck < Solr::Request::Select
+
+ def initialize(params)
+ super('spellchecker')
+ @params = params
+ end
+
+ def to_hash
+ hash = super
+ hash[:q] = @params[:query]
+ hash[:suggestionCount] = @params[:suggestion_count]
+ hash[:accuracy] = @params[:accuracy]
+ hash[:onlyMorePopular] = @params[:only_more_popular]
+ hash[:cmd] = @params[:command]
+ return hash
+ end
+
+end
\ No newline at end of file
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
new file mode 100755
index 0000000..895866f
--- /dev/null
+++ b/vendor/plugins/acts_as_solr_reloaded/lib/solr/request/standard.rb
@@ -0,0 +1,409 @@
+# 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.
+
+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]
+
+ def initialize(params)
+ super(params[:radius].nil? ? 'standard' : 'geo')
+
+ raise "Invalid parameters: #{(params.keys - VALID_PARAMS).join(',')}" unless
+ (params.keys - VALID_PARAMS).empty?
+
+ raise ":query parameter required" unless params[:query]
+
+ @params = params.dup
+
+ # Validate operator
+ if params[:operator]
+ raise "Only :and/:or operators allowed" unless
+ [:and, :or].include?(params[:operator])
+
+ @params[:operator] = params[:operator].to_s.upcase
+ end
+
+ # Validate start, rows can be transformed to ints
+ @params[:start] = params[:start].to_i if params[:start]
+ @params[:rows] = params[:rows].to_i if params[:rows]
+
+ @params[:field_list] ||= ["*","score"]
+
+ @params[:shards] ||= []
+ end
+
+ def to_hash
+ hash = {}
+
+ # standard request param processing
+ hash[:sort] = @params[:sort]
+ hash[:q] = @params[:query]
+ hash["q.op"] = @params[:operator]
+ hash[:df] = @params[:default_field]
+
+ # common parameter processing
+ hash[:start] = @params[:start]
+ hash[:rows] = @params[:rows]
+ hash[:fq] = @params[:filter_queries]
+ hash[:fl] = @params[:field_list].join(',')
+ hash[:debugQuery] = @params[:debug_query]
+ 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
+
+ # facet parameter processing
+ if @params[:facets]
+ # TODO need validation of all that is under the :facets Hash too
+ hash[:facet] = true
+ hash["facet.field"] = []
+ hash["facet.query"] = @params[:facets][:queries]
+ hash["facet.sort"] = @params[:facets][:sort]
+ hash["facet.limit"] = @params[:facets][:limit]
+ hash["facet.missing"] = @params[:facets][:missing]
+ hash["facet.mincount"] = @params[:facets][:mincount]
+ hash["facet.prefix"] = @params[:facets][:prefix]
+ hash["facet.offset"] = @params[:facets][:offset]
+ if @params[:facets][:fields] # facet fields are optional (could be facet.query only)
+ @params[:facets][:fields].each do |f|
+ if f.kind_of? Hash
+ key = f.keys[0]
+ value = f[key]
+ hash["facet.field"] << key
+ hash["f.#{key}.facet.sort"] = value[:sort]
+ hash["f.#{key}.facet.limit"] = value[:limit]
+ hash["f.#{key}.facet.missing"] = value[:missing]
+ hash["f.#{key}.facet.mincount"] = value[:mincount]
+ hash["f.#{key}.facet.prefix"] = value[:prefix]
+ hash["f.#{key}.facet.offset"] = value[:offset]
+ else
+ hash["facet.field"] << f
+ end
+ end
+ end
+
+ if @params[:date_facets]
+ hash["facet.date"] = []
+ if @params[:date_facets][:fields]
+ @params[:date_facets][:fields].each do |f|
+ if f.kind_of? Hash
+ key = f.keys[0]
+ hash["facet.date"] << key
+ f[key].each { |k, v|
+ hash["f.#{key}.facet.date.#{k}"] = v
+ }
+ else
+ hash["facet.date"] << f
+ end
+ end
+ end
+ hash["facet.date.start"] = @params[:date_facets][:start]
+ hash["facet.date.end"] = @params[:date_facets][:end]
+ hash["facet.date.gap"] = @params[:date_facets][:gap]
+ hash["facet.date.other"] = @params[:date_facets][:other]
+ hash["facet.date.hardend"] = @params[:date_facets][:hardend]
+ if @params[:date_facets][:filter]
+ if hash[:fq]
+ hash[:fq] << @params[:date_facets][:filter]
+ else
+ hash[:fq] = @params[:date_facets][:filter]
+ end
+ end
+ end
+ end
+
+ # highlighting parameter processing - http://wiki.apache.org/solr/HighlightingParameters
+ if @params[:highlighting]
+ hash[:hl] = true
+ hash["hl.fl"] = @params[:highlighting][:field_list].join(',') if @params[:highlighting][:field_list]
+
+ snippets = @params[:highlighting][:max_snippets]
+ if snippets
+ if snippets.kind_of? Hash
+ if snippets[:default]
+ hash["hl.snippets"] = snippets[:default]
+ end
+ if snippets[:fields]
+ snippets[:fields].each do |k,v|
+ hash["f.#{k}.hl.snippets"] = v
+ end
+ end
+ else
+ hash["hl.snippets"] = snippets
+ end
+ end
+
+ fragsize = @params[:highlighting][:fragment_size]
+ if fragsize
+ if fragsize.kind_of? Hash
+ if fragsize[:default]
+ hash["hl.fragsize"] = fragsize[:default]
+ end
+ if fragsize[:fields]
+ fragsize[:fields].each do |k,v|
+ hash["f.#{k}.hl.fragsize"] = v
+ end
+ end
+ else
+ hash["hl.fragsize"] = fragsize
+ end
+ end
+
+ rfm = @params[:highlighting][:require_field_match]
+ if nil != rfm
+ if rfm.kind_of? Hash
+ if nil != rfm[:default]
+ hash["hl.requireFieldMatch"] = rfm[:default]
+ end
+ if rfm[:fields]
+ rfm[:fields].each do |k,v|
+ hash["f.#{k}.hl.requireFieldMatch"] = v
+ end
+ end
+ else
+ hash["hl.requireFieldMatch"] = rfm
+ end
+ end
+
+ mac = @params[:highlighting][:max_analyzed_chars]
+ if mac
+ if mac.kind_of? Hash
+ if mac[:default]
+ hash["hl.maxAnalyzedChars"] = mac[:default]
+ end
+ if mac[:fields]
+ mac[:fields].each do |k,v|
+ hash["f.#{k}.hl.maxAnalyzedChars"] = v
+ end
+ end
+ else
+ hash["hl.maxAnalyzedChars"] = mac
+ end
+ end
+
+ prefix = @params[:highlighting][:prefix]
+ if prefix
+ if prefix.kind_of? Hash
+ if prefix[:default]
+ hash["hl.simple.pre"] = prefix[:default]
+ end
+ if prefix[:fields]
+ prefix[:fields].each do |k,v|
+ hash["f.#{k}.hl.simple.pre"] = v
+ end
+ end
+ else
+ hash["hl.simple.pre"] = prefix
+ end
+ end
+
+ suffix = @params[:highlighting][:suffix]
+ if suffix
+ if suffix.kind_of? Hash
+ if suffix[:default]
+ hash["hl.simple.post"] = suffix[:default]
+ end
+ if suffix[:fields]
+ suffix[:fields].each do |k,v|
+ hash["f.#{k}.hl.simple.post"] = v
+ end
+ end
+ else
+ hash["hl.simple.post"] = suffix
+ end
+ end
+
+ formatter = @params[:highlighting][:formatter]
+ if formatter
+ if formatter.kind_of? Hash
+ if formatter[:default]
+ hash["hl.formatter"] = formatter[:default]
+ end
+ if formatter[:fields]
+ formatter[:fields].each do |k,v|
+ hash["f.#{k}.hl.formatter"] = v
+ end
+ end
+ else
+ hash["hl.formatter"] = formatter
+ end
+ end
+
+ fragmenter = @params[:highlighting][:fragmenter]
+ if fragmenter
+ if fragmenter.kind_of? Hash
+ if fragmenter[:default]
+ hash["hl.fragmenter"] = fragmenter[:default]
+ end
+ if fragmenter[:fields]
+ fragmenter[:fields].each do |k,v|
+ hash["f.#{k}.hl.fragmenter"] = v
+ end
+ end
+ else
+ hash["hl.fragmenter"] = fragmenter
+ end
+ end
+
+ merge_contiguous = @params[:highlighting][:merge_contiguous]
+ if nil != merge_contiguous
+ if merge_contiguous.kind_of? Hash
+ if nil != merge_contiguous[:default]
+ hash["hl.mergeContiguous"] = merge_contiguous[:default]
+ end
+ if merge_contiguous[:fields]
+ merge_contiguous[:fields].each do |k,v|
+ hash["f.#{k}.hl.mergeContiguous"] = v
+ end
+ end
+ else
+ hash["hl.mergeContiguous"] = merge_contiguous
+ end
+ end
+
+ increment = @params[:highlighting][:increment]
+ if increment
+ if increment.kind_of? Hash
+ if increment[:default]
+ hash["hl.increment"] = increment[:default]
+ end
+ if increment[:fields]
+ increment[:fields].each do |k,v|
+ hash["f.#{k}.hl.increment"] = v
+ end
+ end
+ else
+ hash["hl.increment"] = increment
+ end
+ end
+
+ # support "old style"
+ alternate_fields = @params[:highlighting][:alternate_fields]
+ if alternate_fields
+ alternate_fields.each do |f,v|
+ hash["f.#{f}.hl.alternateField"] = v
+ end
+ end
+
+ alternate_field = @params[:highlighting][:alternate_field]
+ if alternate_field
+ if alternate_field.kind_of? Hash
+ if alternate_field[:default]
+ hash["hl.alternateField"] = alternate_field[:default]
+ end
+ if alternate_field[:fields]
+ alternate_field[:fields].each do |k,v|
+ hash["f.#{k}.hl.alternateField"] = v
+ end
+ end
+ else
+ hash["hl.alternateField"] = alternate_field
+ end
+ end
+
+ mafl = @params[:highlighting][:max_alternate_field_length]
+ if mafl
+ if mafl.kind_of? Hash
+ if mafl[:default]
+ hash["hl.maxAlternateFieldLength"] = mafl[:default]
+ end
+ if mafl[:fields]
+ mafl[:fields].each do |k,v|
+ hash["f.#{k}.hl.maxAlternateFieldLength"] = v
+ end
+ else
+ # support "old style"
+ mafl.each do |k,v|
+ hash["f.#{k}.hl.maxAlternateFieldLength"] = v
+ end
+ end
+ else
+ hash["hl.maxAlternateFieldLength"] = mafl
+ end
+ end
+
+ hash["hl.usePhraseHighlighter"] = @params[:highlighting][:use_phrase_highlighter]
+
+ regex = @params[:highlighting][:regex]
+ if regex
+ if regex[:slop]
+ if regex[:slop].kind_of? Hash
+ if regex[:slop][:default]
+ hash["hl.regex.slop"] = regex[:slop][:default]
+ end
+ if regex[:slop][:fields]
+ regex[:slop][:fields].each do |k,v|
+ hash["f.#{k}.hl.regex.slop"] = v
+ end
+ end
+ else
+ hash["hl.regex.slop"] = regex[:slop]
+ end
+ end
+ if regex[:pattern]
+ if regex[:pattern].kind_of? Hash
+ if regex[:pattern][:default]
+ hash["hl.regex.pattern"] = regex[:pattern][:default]
+ end
+ if regex[:pattern][:fields]
+ regex[:pattern][:fields].each do |k,v|
+ hash["f.#{k}.hl.regex.pattern"] = v
+ end
+ end
+ else
+ hash["hl.regex.pattern"] = regex[:pattern]
+ end
+ end
+ if regex[:max_analyzed_chars]
+ if regex[:max_analyzed_chars].kind_of? Hash
+ if regex[:max_analyzed_chars][:default]
+ hash["hl.regex.maxAnalyzedChars"] = regex[:max_analyzed_chars][:default]
+ end
+ if regex[:max_analyzed_chars][:fields]
+ regex[:max_analyzed_chars][:fields].each do |k,v|
+ hash["f.#{k}.hl.regex.maxAnalyzedChars"] = v
+ end
+ end
+ else
+ hash["hl.regex.maxAnalyzedChars"] = regex[:max_analyzed_chars]
+ end
+ end
+ end
+
+ end
+
+ if @params[:mlt]
+ hash[:mlt] = true
+ hash["mlt.count"] = @params[:mlt][:count]
+ hash["mlt.fl"] = @params[:mlt][:field_list].join(',')
+ hash["mlt.mintf"] = @params[:mlt][:min_term_freq]
+ hash["mlt.mindf"] = @params[:mlt][:min_doc_freq]
+ hash["mlt.minwl"] = @params[:mlt][:min_word_length]
+ hash["mlt.maxwl"] = @params[:mlt][:max_word_length]
+ hash["mlt.maxqt"] = @params[:mlt][:max_query_terms]
+ hash["mlt.maxntp"] = @params[:mlt][:max_tokens_parsed]
+ hash["mlt.boost"] = @params[:mlt][:boost]
+ end
+
+ hash[:spellcheck] = true
+ hash['spellcheck.collate'] = true
+
+ hash.merge(super.to_hash)
+ end
+
+end
diff --git a/vendor/plugins/acts_as_solr_reloaded/lib/solr/request/update.rb b/vendor/plugins/acts_as_solr_reloaded/lib/solr/request/update.rb
new file mode 100644
index 0000000..8bd8448
--- /dev/null
+++ b/vendor/plugins/acts_as_solr_reloaded/lib/solr/request/update.rb
@@ -0,0 +1,23 @@
+# 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 parent class for all requests that go through the solr update handler
+# TODO: Use new xml update handler for better error responses
+class Solr::Request::Update < Solr::Request::Base
+ def response_format
+ :xml
+ end
+
+ def handler
+ 'update'
+ end
+end
diff --git a/vendor/plugins/acts_as_solr_reloaded/lib/solr/response.rb b/vendor/plugins/acts_as_solr_reloaded/lib/solr/response.rb
new file mode 100755
index 0000000..9df29e6
--- /dev/null
+++ b/vendor/plugins/acts_as_solr_reloaded/lib/solr/response.rb
@@ -0,0 +1,27 @@
+# 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.
+
+module Solr; module Response; end; end
+require File.expand_path("#{File.dirname(__FILE__)}/response/base")
+require File.expand_path("#{File.dirname(__FILE__)}/response/xml")
+require File.expand_path("#{File.dirname(__FILE__)}/response/ruby")
+require File.expand_path("#{File.dirname(__FILE__)}/response/ping")
+require File.expand_path("#{File.dirname(__FILE__)}/response/add_document")
+require File.expand_path("#{File.dirname(__FILE__)}/response/modify_document")
+require File.expand_path("#{File.dirname(__FILE__)}/response/standard")
+require File.expand_path("#{File.dirname(__FILE__)}/response/spellcheck")
+require File.expand_path("#{File.dirname(__FILE__)}/response/dismax")
+require File.expand_path("#{File.dirname(__FILE__)}/response/commit")
+require File.expand_path("#{File.dirname(__FILE__)}/response/delete")
+require File.expand_path("#{File.dirname(__FILE__)}/response/index_info")
+require File.expand_path("#{File.dirname(__FILE__)}/response/optimize")
+require File.expand_path("#{File.dirname(__FILE__)}/response/select")
\ No newline at end of file
diff --git a/vendor/plugins/acts_as_solr_reloaded/lib/solr/response/add_document.rb b/vendor/plugins/acts_as_solr_reloaded/lib/solr/response/add_document.rb
new file mode 100644
index 0000000..d1e1923
--- /dev/null
+++ b/vendor/plugins/acts_as_solr_reloaded/lib/solr/response/add_document.rb
@@ -0,0 +1,17 @@
+# 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.
+
+class Solr::Response::AddDocument < Solr::Response::Xml
+ def initialize(xml)
+ super
+ end
+end
diff --git a/vendor/plugins/acts_as_solr_reloaded/lib/solr/response/base.rb b/vendor/plugins/acts_as_solr_reloaded/lib/solr/response/base.rb
new file mode 100644
index 0000000..a66d2a4
--- /dev/null
+++ b/vendor/plugins/acts_as_solr_reloaded/lib/solr/response/base.rb
@@ -0,0 +1,42 @@
+# 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.
+
+class Solr::Response::Base
+ attr_reader :raw_response
+
+ def initialize(raw_response)
+ @raw_response = raw_response
+ end
+
+ # factory method for creating a Solr::Response::* from
+ # a request and the raw response content
+ def self.make_response(request, raw)
+
+ # make sure response format seems sane
+ unless [:xml, :ruby].include?(request.response_format)
+ raise Solr::Exception.new("unknown response format: #{request.response_format}" )
+ end
+
+ # TODO: Factor out this case... perhaps the request object should provide the response class instead? Or dynamically align by class name?
+ # Maybe the request itself could have the response handling features that get mixed in with a single general purpose response object?
+
+ begin
+ klass = eval(request.class.name.sub(/Request/,'Response'))
+ rescue NameError
+ raise Solr::Exception.new("unknown request type: #{request.class}")
+ else
+ klass.new(raw)
+ end
+
+ end
+
+end
diff --git a/vendor/plugins/acts_as_solr_reloaded/lib/solr/response/commit.rb b/vendor/plugins/acts_as_solr_reloaded/lib/solr/response/commit.rb
new file mode 100644
index 0000000..3a258e6
--- /dev/null
+++ b/vendor/plugins/acts_as_solr_reloaded/lib/solr/response/commit.rb
@@ -0,0 +1,15 @@
+# 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.
+
+class Solr::Response::Commit < Solr::Response::Xml
+end
+
diff --git a/vendor/plugins/acts_as_solr_reloaded/lib/solr/response/delete.rb b/vendor/plugins/acts_as_solr_reloaded/lib/solr/response/delete.rb
new file mode 100644
index 0000000..0836128
--- /dev/null
+++ b/vendor/plugins/acts_as_solr_reloaded/lib/solr/response/delete.rb
@@ -0,0 +1,13 @@
+# 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.
+
+class Solr::Response::Delete < Solr::Response::Xml; end
diff --git a/vendor/plugins/acts_as_solr_reloaded/lib/solr/response/dismax.rb b/vendor/plugins/acts_as_solr_reloaded/lib/solr/response/dismax.rb
new file mode 100644
index 0000000..d495843
--- /dev/null
+++ b/vendor/plugins/acts_as_solr_reloaded/lib/solr/response/dismax.rb
@@ -0,0 +1,8 @@
+class Solr::Response::Dismax < Solr::Response::Standard
+ # no need for special processing
+
+ # FIXME: 2007-02-07 -- The existence of this class indicates that
+ # the Request/Response pair architecture is a little hinky. Perhaps we could refactor
+ # out some of the most common functionality -- Common Query Parameters, Highlighting Parameters,
+ # Simple Facet Parameters, etc. -- into modules?
+end
\ No newline at end of file
diff --git a/vendor/plugins/acts_as_solr_reloaded/lib/solr/response/index_info.rb b/vendor/plugins/acts_as_solr_reloaded/lib/solr/response/index_info.rb
new file mode 100755
index 0000000..b8e215f
--- /dev/null
+++ b/vendor/plugins/acts_as_solr_reloaded/lib/solr/response/index_info.rb
@@ -0,0 +1,26 @@
+# 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.
+
+class Solr::Response::IndexInfo < Solr::Response::Ruby
+ def initialize(ruby_code)
+ super
+ end
+
+ def num_docs
+ return @data['index']['numDocs']
+ end
+
+ def field_names
+ return @data['fields'].keys
+ end
+
+end
diff --git a/vendor/plugins/acts_as_solr_reloaded/lib/solr/response/modify_document.rb b/vendor/plugins/acts_as_solr_reloaded/lib/solr/response/modify_document.rb
new file mode 100644
index 0000000..44c4f5b
--- /dev/null
+++ b/vendor/plugins/acts_as_solr_reloaded/lib/solr/response/modify_document.rb
@@ -0,0 +1,17 @@
+# 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.
+
+class Solr::Response::ModifyDocument < Solr::Response::Xml
+ def initialize(xml)
+ super
+ end
+end
diff --git a/vendor/plugins/acts_as_solr_reloaded/lib/solr/response/optimize.rb b/vendor/plugins/acts_as_solr_reloaded/lib/solr/response/optimize.rb
new file mode 100755
index 0000000..4594d90
--- /dev/null
+++ b/vendor/plugins/acts_as_solr_reloaded/lib/solr/response/optimize.rb
@@ -0,0 +1,14 @@
+# 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.
+
+class Solr::Response::Optimize < Solr::Response::Commit
+end
\ No newline at end of file
diff --git a/vendor/plugins/acts_as_solr_reloaded/lib/solr/response/ping.rb b/vendor/plugins/acts_as_solr_reloaded/lib/solr/response/ping.rb
new file mode 100644
index 0000000..5be1e90
--- /dev/null
+++ b/vendor/plugins/acts_as_solr_reloaded/lib/solr/response/ping.rb
@@ -0,0 +1,26 @@
+# 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.
+
+class Solr::Response::Ping < Solr::Response::Xml
+
+ def initialize(xml)
+ super
+ @ok = REXML::XPath.first(@doc, './solr/ping') ? true : false
+ end
+
+ # returns true or false depending on whether the ping
+ # was successful or not
+ def ok?
+ @ok
+ end
+
+end
diff --git a/vendor/plugins/acts_as_solr_reloaded/lib/solr/response/ruby.rb b/vendor/plugins/acts_as_solr_reloaded/lib/solr/response/ruby.rb
new file mode 100644
index 0000000..05424c1
--- /dev/null
+++ b/vendor/plugins/acts_as_solr_reloaded/lib/solr/response/ruby.rb
@@ -0,0 +1,42 @@
+# 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.
+
+class Solr::Response::Ruby < Solr::Response::Base
+ attr_reader :data, :header
+
+ def initialize(ruby_code)
+ super
+ begin
+ #TODO: what about pulling up data/header/response to ResponseBase,
+ # or maybe a new middle class like SelectResponseBase since
+ # all Select queries return this same sort of stuff??
+ # XML (&wt=xml) and Ruby (&wt=ruby) responses contain exactly the same structure.
+ # a goal of solrb is to make it irrelevant which gets used under the hood,
+ # but favor Ruby responses.
+ @data = eval(ruby_code)
+ @header = @data['responseHeader']
+ raise "response should be a hash" unless @data.kind_of? Hash
+ raise "response header missing" unless @header.kind_of? Hash
+ rescue SyntaxError => e
+ raise Solr::Exception.new("invalid ruby code: #{e}")
+ end
+ end
+
+ def ok?
+ @header['status'] == 0
+ end
+
+ def query_time
+ @header['QTime']
+ end
+
+end
diff --git a/vendor/plugins/acts_as_solr_reloaded/lib/solr/response/select.rb b/vendor/plugins/acts_as_solr_reloaded/lib/solr/response/select.rb
new file mode 100644
index 0000000..8e2185d
--- /dev/null
+++ b/vendor/plugins/acts_as_solr_reloaded/lib/solr/response/select.rb
@@ -0,0 +1,17 @@
+# 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.
+
+class Solr::Response::Select < Solr::Response::Ruby
+ def initialize(ruby_code)
+ super
+ end
+end
diff --git a/vendor/plugins/acts_as_solr_reloaded/lib/solr/response/spellcheck.rb b/vendor/plugins/acts_as_solr_reloaded/lib/solr/response/spellcheck.rb
new file mode 100644
index 0000000..a4842c5
--- /dev/null
+++ b/vendor/plugins/acts_as_solr_reloaded/lib/solr/response/spellcheck.rb
@@ -0,0 +1,20 @@
+# 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.
+
+class Solr::Response::Spellcheck < Solr::Response::Ruby
+ attr_reader :suggestions
+
+ def initialize(ruby_code)
+ super
+ @suggestions = @data['suggestions']
+ end
+end
diff --git a/vendor/plugins/acts_as_solr_reloaded/lib/solr/response/standard.rb b/vendor/plugins/acts_as_solr_reloaded/lib/solr/response/standard.rb
new file mode 100644
index 0000000..91bf7db
--- /dev/null
+++ b/vendor/plugins/acts_as_solr_reloaded/lib/solr/response/standard.rb
@@ -0,0 +1,65 @@
+# 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.
+
+class Solr::Response::Standard < Solr::Response::Ruby
+ FacetValue = Struct.new(:name, :value)
+ include Enumerable
+
+ def initialize(ruby_code)
+ super
+ @response = @data['response']
+ raise "response section missing" unless @response.kind_of? Hash
+ end
+
+ def total_hits
+ @response['numFound']
+ end
+
+ def start
+ @response['start']
+ end
+
+ def hits
+ @response['docs']
+ end
+
+ def max_score
+ @response['maxScore']
+ end
+
+ # TODO: consider the use of json.nl parameter
+ def field_facets(field)
+ facets = []
+ values = @data['facet_counts']['facet_fields'][field]
+ Solr::Util.paired_array_each(values) do |key, value|
+ facets << FacetValue.new(key, value)
+ end
+
+ facets
+ end
+
+ def highlighted(id, field)
+ @data['highlighting'][id.to_s][field.to_s] rescue nil
+ end
+
+ def highlighting
+ @data['highlighting']
+ end
+
+ # supports enumeration of hits
+ # TODO revisit - should this iterate through *all* hits by re-requesting more?
+ def each
+ @response['docs'].each {|hit| yield hit}
+ end
+
+end
+
diff --git a/vendor/plugins/acts_as_solr_reloaded/lib/solr/response/xml.rb b/vendor/plugins/acts_as_solr_reloaded/lib/solr/response/xml.rb
new file mode 100644
index 0000000..1fff3ed
--- /dev/null
+++ b/vendor/plugins/acts_as_solr_reloaded/lib/solr/response/xml.rb
@@ -0,0 +1,39 @@
+# 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.
+
+class Solr::Response::Xml < Solr::Response::Base
+ attr_reader :doc, :status_code, :status_message
+
+ def initialize(xml)
+ super
+ # parse the xml
+ @doc = REXML::Document.new(xml)
+
+ # look for the result code and string
+ #
+ #
+ # 02
+ #
+ result = REXML::XPath.first(@doc, './response/lst[@name="responseHeader"]/int[@name="status"]')
+ if result
+ @status_code = result.text
+ @status_message = result.text # TODO: any need for a message?
+ end
+ rescue REXML::ParseException => e
+ raise Solr::Exception.new("invalid response xml: #{e}")
+ end
+
+ def ok?
+ return @status_code == '0'
+ end
+
+end
diff --git a/vendor/plugins/acts_as_solr_reloaded/lib/solr/solrtasks.rb b/vendor/plugins/acts_as_solr_reloaded/lib/solr/solrtasks.rb
new file mode 100755
index 0000000..3a1f76a
--- /dev/null
+++ b/vendor/plugins/acts_as_solr_reloaded/lib/solr/solrtasks.rb
@@ -0,0 +1,27 @@
+#!/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/solr/util.rb b/vendor/plugins/acts_as_solr_reloaded/lib/solr/util.rb
new file mode 100755
index 0000000..bb134ee
--- /dev/null
+++ b/vendor/plugins/acts_as_solr_reloaded/lib/solr/util.rb
@@ -0,0 +1,32 @@
+# 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.
+
+class Solr::Util
+ # paired_array_each([key1,value1,key2,value2]) yields twice:
+ # |key1,value1| and |key2,value2|
+ def self.paired_array_each(a, &block)
+ 0.upto(a.size / 2 - 1) do |i|
+ n = i * 2
+ yield(a[n], a[n+1])
+ end
+ end
+
+ # paired_array_to_hash([key1,value1,key2,value2]) => {key1 => value1, key2, value2}
+ def self.paired_array_to_hash(a)
+ Hash[*a]
+ end
+
+ def self.query_parser_escape(string)
+ # backslash prefix everything that isn't a word character
+ string.gsub(/(\W)/,'\\\\\1')
+ end
+end
diff --git a/vendor/plugins/acts_as_solr_reloaded/lib/solr/xml.rb b/vendor/plugins/acts_as_solr_reloaded/lib/solr/xml.rb
new file mode 100644
index 0000000..af913d7
--- /dev/null
+++ b/vendor/plugins/acts_as_solr_reloaded/lib/solr/xml.rb
@@ -0,0 +1,43 @@
+# 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.
+
+module Solr::XML
+end
+
+begin
+
+ # If we can load rubygems and libxml-ruby...
+ require 'rubygems'
+ require 'xml/libxml'
+ raise "acts_as_solr requires libxml-ruby 0.7 or greater" unless XML::Node.public_instance_methods.collect{|x| x.to_sym}.include?(:attributes)
+
+ # then make a few modifications to XML::Node so it can stand in for REXML::Element
+ class XML::Node
+ # element.add_element(another_element) should work
+ alias_method :add_element, :<<
+
+
+ # element.text = "blah" should work
+ def text=(x)
+ self << x.to_s
+ end
+ end
+
+ # And use XML::Node for our XML generation
+ Solr::XML::Element = XML::Node
+
+rescue LoadError => e # If we can't load either rubygems or libxml-ruby
+ # Just use REXML.
+ require 'rexml/document'
+ Solr::XML::Element = REXML::Element
+
+end
diff --git a/vendor/plugins/acts_as_solr_reloaded/lib/tasks/database.rake b/vendor/plugins/acts_as_solr_reloaded/lib/tasks/database.rake
new file mode 100644
index 0000000..ea63419
--- /dev/null
+++ b/vendor/plugins/acts_as_solr_reloaded/lib/tasks/database.rake
@@ -0,0 +1,16 @@
+namespace :db do
+ namespace :fixtures do
+ desc "Load fixtures into the current environment's database. Load specific fixtures using FIXTURES=x,y"
+ task :load => :environment do
+ begin
+ ActsAsSolr::Post.execute(Solr::Request::Delete.new(:query => "*:*"))
+ ActsAsSolr::Post.execute(Solr::Request::Commit.new)
+ (ENV['FIXTURES'] ? ENV['FIXTURES'].split(/,/) : Dir.glob(File.join(RAILS_ROOT, 'test', 'fixtures', '*.{yml,csv}'))).each do |fixture_file|
+ ActsAsSolr::SolrFixtures.load(File.basename(fixture_file, '.*'))
+ end
+ puts "The fixtures loaded have been added to Solr"
+ rescue
+ end
+ end
+ end
+end
\ No newline at end of file
diff --git a/vendor/plugins/acts_as_solr_reloaded/lib/tasks/solr.rake b/vendor/plugins/acts_as_solr_reloaded/lib/tasks/solr.rake
new file mode 100644
index 0000000..16617a0
--- /dev/null
+++ b/vendor/plugins/acts_as_solr_reloaded/lib/tasks/solr.rake
@@ -0,0 +1,169 @@
+namespace :solr do
+
+ desc 'Download and install Solr+Jetty 3.3.0.'
+ task :download do
+ if (File.exists?(Rails.root + '/vendor/plugins/acts_as_solr_reloaded/solr/start.jar'))
+ puts 'Solr already downloaded.'
+ else
+ cd '/tmp'
+ sh 'wget -c http://ftp.unicamp.br/pub/apache/lucene/solr/3.3.0/apache-solr-3.3.0.tgz'
+ sh 'tar xzf apache-solr-3.3.0.tgz'
+ cd 'apache-solr-3.3.0/example'
+ cp_r ['../LICENSE.txt', '../NOTICE.txt', 'README.txt', 'etc', 'lib', 'start.jar', 'webapps', 'work'], Rails.root + '/vendor/plugins/acts_as_solr_reloaded/solr', :verbose => true
+ cd 'solr'
+ cp_r ['README.txt', 'bin', 'solr.xml'], Rails.root + '/vendor/plugins/acts_as_solr_reloaded/solr/solr', :verbose => true
+ end
+ end
+
+ desc 'Remove Solr instalation from the tree.'
+ task :remove do
+ solr_root = Rails.root + '/vendor/plugins/acts_as_solr_reloaded/solr/'
+ rm_r ['README.txt', 'bin', 'solr.xml'].map{ |i| File.join(solr_root, 'solr', i) }, :verbose => true, :force => true
+ rm_r ['LICENSE.txt', 'NOTICE.txt', 'README.txt', 'etc', 'lib', 'start.jar', 'webapps', 'work'].map{ |i| File.join(solr_root, i) }, :verbose => true, :force => true
+ end
+
+ desc 'Update to the newest supported version of solr'
+ task :update => [:remove, :download] do
+ end
+
+ desc 'Starts Solr. Options accepted: RAILS_ENV=your_env, PORT=XX. Defaults to development if none.'
+ task :start => :environment do
+ require File.expand_path("#{File.dirname(__FILE__)}/../../config/solr_environment")
+ FileUtils.mkdir_p(SOLR_LOGS_PATH)
+ FileUtils.mkdir_p(SOLR_DATA_PATH)
+ FileUtils.mkdir_p(SOLR_PIDS_PATH)
+ begin
+ n = Net::HTTP.new('127.0.0.1', SOLR_PORT)
+ n.request_head('/').value
+
+ rescue Net::HTTPServerException #responding
+ puts "Port #{SOLR_PORT} in use" and return
+
+ rescue Errno::ECONNREFUSED, Errno::EBADF, NoMethodError #not responding
+ # there's an issue with Net::HTTP.request where @socket is nil and raises a NoMethodError
+ # http://redmine.ruby-lang.org/issues/show/2708
+ Dir.chdir(SOLR_PATH) do
+ cmd = "java #{SOLR_JVM_OPTIONS} -Djetty.logs=\"#{SOLR_LOGS_PATH}\" -Dsolr.solr.home=\"#{SOLR_CONFIG_PATH}\" -Dsolr.data.dir=\"#{SOLR_DATA_PATH}\" -Djetty.host=\"#{SOLR_HOST}\" -Djetty.port=#{SOLR_PORT} -jar start.jar"
+ puts "Executing: " + cmd
+ windows = RUBY_PLATFORM =~ /(win|w)32$/
+ if windows
+ exec cmd
+ else
+ pid = fork do
+ STDERR.close
+ exec cmd
+ end
+ end
+ sleep(5)
+ File.open(SOLR_PID_FILE, "w"){ |f| f << pid} unless windows
+ puts "#{ENV['RAILS_ENV']} Solr started successfully on #{SOLR_HOST}:#{SOLR_PORT}, pid: #{pid}."
+ end
+ end
+ end
+
+ desc 'Stops Solr. Specify the environment by using: RAILS_ENV=your_env. Defaults to development if none.'
+ task :stop=> :environment do
+ require File.expand_path("#{File.dirname(__FILE__)}/../../config/solr_environment")
+ fork do
+ if File.exists?(SOLR_PID_FILE)
+ File.open(SOLR_PID_FILE, "r") do |f|
+ pid = f.readline
+ Process.kill('TERM', pid.to_i)
+ end
+ File.unlink(SOLR_PID_FILE)
+ Rake::Task["solr:destroy_index"].invoke if ENV['RAILS_ENV'] == 'test'
+ puts "Solr shutdown successfully."
+ else
+ puts "PID file not found at #{SOLR_PID_FILE}. Either Solr is not running or no PID file was written."
+ end
+ end
+ end
+
+ desc 'Remove Solr index'
+ task :destroy_index => :environment do
+ require File.expand_path("#{File.dirname(__FILE__)}/../../config/solr_environment")
+ raise "In production mode. I'm not going to delete the index, sorry." if ENV['RAILS_ENV'] == "production"
+ if File.exists?("#{SOLR_DATA_PATH}")
+ Dir["#{SOLR_DATA_PATH}/index/*"].each{|f| File.unlink(f) if File.exists?(f)}
+ Dir.rmdir("#{SOLR_DATA_PATH}/index")
+ puts "Index files removed under " + ENV['RAILS_ENV'] + " environment"
+ end
+ end
+
+ # this task is by Henrik Nyh
+ # http://henrik.nyh.se/2007/06/rake-task-to-reindex-models-for-acts_as_solr
+ desc %{Reindexes data for all acts_as_solr models. Clears index first to get rid of orphaned records and optimizes index afterwards. RAILS_ENV=your_env to set environment. ONLY=book,person,magazine to only reindex those models; EXCEPT=book,magazine to exclude those models. START_SERVER=true to solr:start before and solr:stop after. BATCH=123 to post/commit in batches of that size: default is 300. CLEAR=false to not clear the index first; OPTIMIZE=false to not optimize the index afterwards.}
+ task :reindex => :environment do
+ require File.expand_path("#{File.dirname(__FILE__)}/../../config/solr_environment")
+
+ includes = env_array_to_constants('ONLY')
+ if includes.empty?
+ includes = Dir.glob("#{RAILS_ROOT}/app/models/*.rb").map { |path| File.basename(path, ".rb").camelize.constantize }
+ end
+ excludes = env_array_to_constants('EXCEPT')
+ includes -= excludes
+
+ optimize = env_to_bool('OPTIMIZE', true)
+ start_server = env_to_bool('START_SERVER', false)
+ clear_first = env_to_bool('CLEAR', true)
+ batch_size = ENV['BATCH'].to_i.nonzero? || 300
+ debug_output = env_to_bool("DEBUG", false)
+
+ RAILS_DEFAULT_LOGGER.level = ActiveSupport::BufferedLogger::INFO unless debug_output
+
+ if start_server
+ puts "Starting Solr server..."
+ Rake::Task["solr:start"].invoke
+ end
+
+ # Disable solr_optimize
+ module ActsAsSolr::CommonMethods
+ def blank() end
+ alias_method :deferred_solr_optimize, :solr_optimize
+ alias_method :solr_optimize, :blank
+ end
+
+ models = includes.select { |m| m.respond_to?(:rebuild_solr_index) }
+ 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)
+ end
+
+ puts "Rebuilding index for #{model}..."
+ model.rebuild_solr_index(batch_size)
+
+ end
+
+ if models.empty?
+ puts "There were no models to reindex."
+ elsif optimize
+ puts "Optimizing..."
+ models.last.deferred_solr_optimize
+ end
+
+ if start_server
+ puts "Shutting down Solr server..."
+ Rake::Task["solr:stop"].invoke
+ end
+
+ end
+
+ def env_array_to_constants(env)
+ env = ENV[env] || ''
+ env.split(/\s*,\s*/).map { |m| m.singularize.camelize.constantize }.uniq
+ end
+
+ def env_to_bool(env, default)
+ env = ENV[env] || ''
+ case env
+ when /^true$/i then true
+ when /^false$/i then false
+ else default
+ end
+ end
+
+end
+
diff --git a/vendor/plugins/acts_as_solr_reloaded/lib/tasks/test.rake b/vendor/plugins/acts_as_solr_reloaded/lib/tasks/test.rake
new file mode 100644
index 0000000..c1c420b
--- /dev/null
+++ b/vendor/plugins/acts_as_solr_reloaded/lib/tasks/test.rake
@@ -0,0 +1,5 @@
+namespace :test do
+ task :migrate do
+ ActiveRecord::Migrator.migrate("test/db/migrate/", ENV["VERSION"] ? ENV["VERSION"].to_i : nil)
+ end
+end
diff --git a/vendor/plugins/acts_as_solr_reloaded/rails/init.rb b/vendor/plugins/acts_as_solr_reloaded/rails/init.rb
new file mode 100644
index 0000000..fb35c55
--- /dev/null
+++ b/vendor/plugins/acts_as_solr_reloaded/rails/init.rb
@@ -0,0 +1 @@
+require 'acts_as_solr'
\ No newline at end of file
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
new file mode 100755
index 0000000..aa739da
--- /dev/null
+++ b/vendor/plugins/acts_as_solr_reloaded/solr/solr/conf/admin-extra.html
@@ -0,0 +1,31 @@
+
+
+
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
new file mode 100755
index 0000000..b91e75c
--- /dev/null
+++ b/vendor/plugins/acts_as_solr_reloaded/solr/solr/conf/elevate.xml
@@ -0,0 +1,36 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
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
new file mode 100755
index 0000000..c441043
--- /dev/null
+++ b/vendor/plugins/acts_as_solr_reloaded/solr/solr/conf/mapping-ISOLatin1Accent.txt
@@ -0,0 +1,246 @@
+# 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.
+
+# Syntax:
+# "source" => "target"
+# "source".length() > 0 (source cannot be empty.)
+# "target".length() >= 0 (target can be empty.)
+
+# example:
+# "À" => "A"
+# "\u00C0" => "A"
+# "\u00C0" => "\u0041"
+# "ß" => "ss"
+# "\t" => " "
+# "\n" => ""
+
+# À => A
+"\u00C0" => "A"
+
+# Á => A
+"\u00C1" => "A"
+
+# Â => A
+"\u00C2" => "A"
+
+# Ã => A
+"\u00C3" => "A"
+
+# Ä => A
+"\u00C4" => "A"
+
+# Å => A
+"\u00C5" => "A"
+
+# Æ => AE
+"\u00C6" => "AE"
+
+# Ç => C
+"\u00C7" => "C"
+
+# È => E
+"\u00C8" => "E"
+
+# É => E
+"\u00C9" => "E"
+
+# Ê => E
+"\u00CA" => "E"
+
+# Ë => E
+"\u00CB" => "E"
+
+# Ì => I
+"\u00CC" => "I"
+
+# Í => I
+"\u00CD" => "I"
+
+# Î => I
+"\u00CE" => "I"
+
+# Ï => I
+"\u00CF" => "I"
+
+# IJ => IJ
+"\u0132" => "IJ"
+
+# Ð => D
+"\u00D0" => "D"
+
+# Ñ => N
+"\u00D1" => "N"
+
+# Ò => O
+"\u00D2" => "O"
+
+# Ó => O
+"\u00D3" => "O"
+
+# Ô => O
+"\u00D4" => "O"
+
+# Õ => O
+"\u00D5" => "O"
+
+# Ö => O
+"\u00D6" => "O"
+
+# Ø => O
+"\u00D8" => "O"
+
+# Œ => OE
+"\u0152" => "OE"
+
+# Þ
+"\u00DE" => "TH"
+
+# Ù => U
+"\u00D9" => "U"
+
+# Ú => U
+"\u00DA" => "U"
+
+# Û => U
+"\u00DB" => "U"
+
+# Ü => U
+"\u00DC" => "U"
+
+# Ý => Y
+"\u00DD" => "Y"
+
+# Ÿ => Y
+"\u0178" => "Y"
+
+# à => a
+"\u00E0" => "a"
+
+# á => a
+"\u00E1" => "a"
+
+# â => a
+"\u00E2" => "a"
+
+# ã => a
+"\u00E3" => "a"
+
+# ä => a
+"\u00E4" => "a"
+
+# å => a
+"\u00E5" => "a"
+
+# æ => ae
+"\u00E6" => "ae"
+
+# ç => c
+"\u00E7" => "c"
+
+# è => e
+"\u00E8" => "e"
+
+# é => e
+"\u00E9" => "e"
+
+# ê => e
+"\u00EA" => "e"
+
+# ë => e
+"\u00EB" => "e"
+
+# ì => i
+"\u00EC" => "i"
+
+# í => i
+"\u00ED" => "i"
+
+# î => i
+"\u00EE" => "i"
+
+# ï => i
+"\u00EF" => "i"
+
+# ij => ij
+"\u0133" => "ij"
+
+# ð => d
+"\u00F0" => "d"
+
+# ñ => n
+"\u00F1" => "n"
+
+# ò => o
+"\u00F2" => "o"
+
+# ó => o
+"\u00F3" => "o"
+
+# ô => o
+"\u00F4" => "o"
+
+# õ => o
+"\u00F5" => "o"
+
+# ö => o
+"\u00F6" => "o"
+
+# ø => o
+"\u00F8" => "o"
+
+# œ => oe
+"\u0153" => "oe"
+
+# ß => ss
+"\u00DF" => "ss"
+
+# þ => th
+"\u00FE" => "th"
+
+# ù => u
+"\u00F9" => "u"
+
+# ú => u
+"\u00FA" => "u"
+
+# û => u
+"\u00FB" => "u"
+
+# ü => u
+"\u00FC" => "u"
+
+# ý => y
+"\u00FD" => "y"
+
+# ÿ => y
+"\u00FF" => "y"
+
+# ff => ff
+"\uFB00" => "ff"
+
+# fi => fi
+"\uFB01" => "fi"
+
+# fl => fl
+"\uFB02" => "fl"
+
+# ffi => ffi
+"\uFB03" => "ffi"
+
+# ffl => ffl
+"\uFB04" => "ffl"
+
+# ſt => ft
+"\uFB05" => "ft"
+
+# st => st
+"\uFB06" => "st"
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
new file mode 100755
index 0000000..5a32e50
--- /dev/null
+++ b/vendor/plugins/acts_as_solr_reloaded/solr/solr/conf/protwords.txt
@@ -0,0 +1,21 @@
+# 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
new file mode 100755
index 0000000..4f39234
--- /dev/null
+++ b/vendor/plugins/acts_as_solr_reloaded/solr/solr/conf/schema.xml
@@ -0,0 +1,147 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ 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
new file mode 100755
index 0000000..f58b262
--- /dev/null
+++ b/vendor/plugins/acts_as_solr_reloaded/solr/solr/conf/scripts.conf
@@ -0,0 +1,24 @@
+# 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.
+
+user=
+solr_hostname=localhost
+solr_port=8983
+rsyncd_port=18983
+data_dir=
+webapp_name=solr
+master_host=
+master_data_dir=
+master_status_dir=
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
new file mode 100755
index 0000000..3ebd2ea
--- /dev/null
+++ b/vendor/plugins/acts_as_solr_reloaded/solr/solr/conf/solrconfig.xml
@@ -0,0 +1,898 @@
+
+
+
+
+
+ ${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
+
+
+
+
+
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
new file mode 100755
index 0000000..44b748d
--- /dev/null
+++ b/vendor/plugins/acts_as_solr_reloaded/solr/solr/conf/spellings.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/stopwords.txt b/vendor/plugins/acts_as_solr_reloaded/solr/solr/conf/stopwords.txt
new file mode 100755
index 0000000..22f277f
--- /dev/null
+++ b/vendor/plugins/acts_as_solr_reloaded/solr/solr/conf/stopwords.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/synonyms.txt b/vendor/plugins/acts_as_solr_reloaded/solr/solr/conf/synonyms.txt
new file mode 100755
index 0000000..453eb31
--- /dev/null
+++ b/vendor/plugins/acts_as_solr_reloaded/solr/solr/conf/synonyms.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/xslt/example.xsl b/vendor/plugins/acts_as_solr_reloaded/solr/solr/conf/xslt/example.xsl
new file mode 100755
index 0000000..6832a1d
--- /dev/null
+++ b/vendor/plugins/acts_as_solr_reloaded/solr/solr/conf/xslt/example.xsl
@@ -0,0 +1,132 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ This has been formatted by the sample "example.xsl" transform -
+ use your own XSLT to get a nicer page
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ |
+
+
+
+
+
+
+ javascript:toggle("");?
+
+
+ exp
+
+
+
+
+
+
+ |
+
+
+
+
+
+
+
+ |
+
+
+ |
+
+
+
+
+
+
+
+
+ |
+
+
+ |
+
+
+
+
+
+
+
+
+
+
+
diff --git a/vendor/plugins/acts_as_solr_reloaded/solr/solr/conf/xslt/example_atom.xsl b/vendor/plugins/acts_as_solr_reloaded/solr/solr/conf/xslt/example_atom.xsl
new file mode 100755
index 0000000..dbc7afa
--- /dev/null
+++ b/vendor/plugins/acts_as_solr_reloaded/solr/solr/conf/xslt/example_atom.xsl
@@ -0,0 +1,67 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+ Example Solr Atom 1.0 Feed
+
+ This has been formatted by the sample "example_atom.xsl" transform -
+ use your own XSLT to get a nicer Atom feed.
+
+
+ Apache Solr
+ solr-user@lucene.apache.org
+
+
+
+
+
+ tag:localhost,2007:example
+
+
+
+
+
+
+
+
+
+
+ tag:localhost,2007:
+
+
+
+
+
+
diff --git a/vendor/plugins/acts_as_solr_reloaded/solr/solr/conf/xslt/example_rss.xsl b/vendor/plugins/acts_as_solr_reloaded/solr/solr/conf/xslt/example_rss.xsl
new file mode 100755
index 0000000..b5bd0cf
--- /dev/null
+++ b/vendor/plugins/acts_as_solr_reloaded/solr/solr/conf/xslt/example_rss.xsl
@@ -0,0 +1,66 @@
+
+
+
+
+
+
+
+
+
+
+
+
+ Example Solr RSS 2.0 Feed
+ http://localhost:8983/solr
+
+ This has been formatted by the sample "example_rss.xsl" transform -
+ use your own XSLT to get a nicer RSS feed.
+
+ en-us
+ http://localhost:8983/solr
+
+
+
+
+
+
+
+
+
+ -
+
+
+ http://localhost:8983/solr/select?q=id:
+
+
+
+
+
+
+ http://localhost:8983/solr/select?q=id:
+
+
+
+
diff --git a/vendor/plugins/acts_as_solr_reloaded/solr/solr/conf/xslt/luke.xsl b/vendor/plugins/acts_as_solr_reloaded/solr/solr/conf/xslt/luke.xsl
new file mode 100755
index 0000000..d3f71c6
--- /dev/null
+++ b/vendor/plugins/acts_as_solr_reloaded/solr/solr/conf/xslt/luke.xsl
@@ -0,0 +1,337 @@
+
+
+
+
+
+
+
+
+ Solr Luke Request Handler Response
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ Index Statistics
+
+
+
+ Field Statistics
+
+
+
+ Document statistics
+
+
+
+
+
+
+
+
+
+
+
+
+
+ |
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ |
+
+
+
+
+
+
+
+
+ |
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ 50
+ 800
+ 160
+ blue
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ background-color: ; width: px; height: px;
+
+ |
+
+
+
+
+
+
+ |
+
+
+
+
+
+
+
+
+
+
+
+
+ |
+
+
+ |
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ |
+
+
+ |
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ |
+
+
+
+
+
+
+
+
+
+
+
+ |
+
+
+
+
+ 1
+
+
+
+
+
+
+
+ -
+
+ -
+
+ -
+
+ -
+
+ -
+
+ -
+
+ -
+
+ -
+
+ -
+
+ -
+
+ -
+
+ -
+
+ -
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/vendor/plugins/acts_as_solr_reloaded/solr_test_rakefile.rb b/vendor/plugins/acts_as_solr_reloaded/solr_test_rakefile.rb
new file mode 100644
index 0000000..8f711f5
--- /dev/null
+++ b/vendor/plugins/acts_as_solr_reloaded/solr_test_rakefile.rb
@@ -0,0 +1,6 @@
+require 'rubygems'
+require 'rake'
+dir = File.dirname(__FILE__)
+$:.unshift("#{dir}/lib")
+RAILS_ROOT = dir
+require "acts_as_solr/tasks"
diff --git a/vendor/plugins/acts_as_solr_reloaded/test/config/solr.yml b/vendor/plugins/acts_as_solr_reloaded/test/config/solr.yml
new file mode 100644
index 0000000..89f6f3f
--- /dev/null
+++ b/vendor/plugins/acts_as_solr_reloaded/test/config/solr.yml
@@ -0,0 +1,2 @@
+test:
+ url: http://localhost:8981/solr
\ No newline at end of file
diff --git a/vendor/plugins/acts_as_solr_reloaded/test/db/connections/mysql/connection.rb b/vendor/plugins/acts_as_solr_reloaded/test/db/connections/mysql/connection.rb
new file mode 100644
index 0000000..aef0a8c
--- /dev/null
+++ b/vendor/plugins/acts_as_solr_reloaded/test/db/connections/mysql/connection.rb
@@ -0,0 +1,11 @@
+require 'logger'
+ActiveRecord::Base.logger = Logger.new("debug.log")
+
+ActiveRecord::Base.establish_connection(
+ :adapter => "mysql",
+ :username => "root",
+ :password => "rotz2od",
+ :encoding => "utf8",
+ :database => "actsassolr_test"
+)
+
diff --git a/vendor/plugins/acts_as_solr_reloaded/test/db/connections/sqlite/connection.rb b/vendor/plugins/acts_as_solr_reloaded/test/db/connections/sqlite/connection.rb
new file mode 100644
index 0000000..b8e6348
--- /dev/null
+++ b/vendor/plugins/acts_as_solr_reloaded/test/db/connections/sqlite/connection.rb
@@ -0,0 +1,8 @@
+require 'logger'
+ActiveRecord::Base.logger = Logger.new("debug.log")
+
+ActiveRecord::Base.establish_connection(
+ :adapter => "sqlite3",
+ :encoding => "utf8",
+ :database => File.join(File.dirname(File.expand_path(__FILE__)), '..', '..', 'test.db')
+)
diff --git a/vendor/plugins/acts_as_solr_reloaded/test/db/migrate/001_create_books.rb b/vendor/plugins/acts_as_solr_reloaded/test/db/migrate/001_create_books.rb
new file mode 100644
index 0000000..35e4586
--- /dev/null
+++ b/vendor/plugins/acts_as_solr_reloaded/test/db/migrate/001_create_books.rb
@@ -0,0 +1,15 @@
+class CreateBooks < ActiveRecord::Migration
+ def self.up
+ create_table :books, :force => true do |t|
+ t.column :category_id, :integer
+ t.column :name, :string
+ t.column :author, :string
+ t.column :type, :string
+ t.column :published_on, :date
+ end
+ end
+
+ def self.down
+ drop_table :books
+ end
+end
diff --git a/vendor/plugins/acts_as_solr_reloaded/test/db/migrate/002_create_movies.rb b/vendor/plugins/acts_as_solr_reloaded/test/db/migrate/002_create_movies.rb
new file mode 100644
index 0000000..ebd7541
--- /dev/null
+++ b/vendor/plugins/acts_as_solr_reloaded/test/db/migrate/002_create_movies.rb
@@ -0,0 +1,12 @@
+class CreateMovies < ActiveRecord::Migration
+ def self.up
+ create_table :movies, :force => true do |t|
+ t.column :name, :string
+ t.column :description, :string
+ end
+ end
+
+ def self.down
+ drop_table :movies
+ end
+end
diff --git a/vendor/plugins/acts_as_solr_reloaded/test/db/migrate/003_create_categories.rb b/vendor/plugins/acts_as_solr_reloaded/test/db/migrate/003_create_categories.rb
new file mode 100644
index 0000000..742e3e7
--- /dev/null
+++ b/vendor/plugins/acts_as_solr_reloaded/test/db/migrate/003_create_categories.rb
@@ -0,0 +1,11 @@
+class CreateCategories < ActiveRecord::Migration
+ def self.up
+ create_table :categories, :force => true do |t|
+ t.column :name, :string
+ end
+ end
+
+ def self.down
+ drop_table :categories
+ end
+end
diff --git a/vendor/plugins/acts_as_solr_reloaded/test/db/migrate/004_create_electronics.rb b/vendor/plugins/acts_as_solr_reloaded/test/db/migrate/004_create_electronics.rb
new file mode 100644
index 0000000..03ceeef
--- /dev/null
+++ b/vendor/plugins/acts_as_solr_reloaded/test/db/migrate/004_create_electronics.rb
@@ -0,0 +1,16 @@
+class CreateElectronics < ActiveRecord::Migration
+ def self.up
+ create_table :electronics, :force => true do |t|
+ t.column :name, :string
+ t.column :manufacturer, :string
+ t.column :features, :string
+ t.column :category, :string
+ t.column :price, :string
+ t.timestamps
+ end
+ end
+
+ def self.down
+ drop_table :electronics
+ end
+end
diff --git a/vendor/plugins/acts_as_solr_reloaded/test/db/migrate/005_create_authors.rb b/vendor/plugins/acts_as_solr_reloaded/test/db/migrate/005_create_authors.rb
new file mode 100644
index 0000000..0edb4d5
--- /dev/null
+++ b/vendor/plugins/acts_as_solr_reloaded/test/db/migrate/005_create_authors.rb
@@ -0,0 +1,12 @@
+class CreateAuthors < ActiveRecord::Migration
+ def self.up
+ create_table :authors, :force => true do |t|
+ t.column :name, :string
+ t.column :biography, :text
+ end
+ end
+
+ def self.down
+ drop_table :authors
+ end
+end
diff --git a/vendor/plugins/acts_as_solr_reloaded/test/db/migrate/006_create_postings.rb b/vendor/plugins/acts_as_solr_reloaded/test/db/migrate/006_create_postings.rb
new file mode 100644
index 0000000..4fc7863
--- /dev/null
+++ b/vendor/plugins/acts_as_solr_reloaded/test/db/migrate/006_create_postings.rb
@@ -0,0 +1,9 @@
+class CreatePostings < ActiveRecord::Migration
+ def self.up
+ execute "CREATE TABLE postings(`guid` varchar(20) NOT NULL PRIMARY KEY, `name` varchar(200), `description` text)"
+ end
+
+ def self.down
+ drop_table :postings
+ end
+end
diff --git a/vendor/plugins/acts_as_solr_reloaded/test/db/migrate/007_create_posts.rb b/vendor/plugins/acts_as_solr_reloaded/test/db/migrate/007_create_posts.rb
new file mode 100644
index 0000000..03f765d
--- /dev/null
+++ b/vendor/plugins/acts_as_solr_reloaded/test/db/migrate/007_create_posts.rb
@@ -0,0 +1,13 @@
+class CreatePosts < ActiveRecord::Migration
+ def self.up
+ create_table :posts, :force => true do |t|
+ t.column :name, :string
+ t.column :reply_counter, :integer
+ t.column :posted_at, :datetime
+ end
+ end
+
+ def self.down
+ drop_table :posts
+ end
+end
diff --git a/vendor/plugins/acts_as_solr_reloaded/test/db/migrate/008_create_gadgets.rb b/vendor/plugins/acts_as_solr_reloaded/test/db/migrate/008_create_gadgets.rb
new file mode 100644
index 0000000..e0acba7
--- /dev/null
+++ b/vendor/plugins/acts_as_solr_reloaded/test/db/migrate/008_create_gadgets.rb
@@ -0,0 +1,11 @@
+class CreateGadgets < ActiveRecord::Migration
+ def self.up
+ create_table :gadgets, :force => true do |t|
+ t.column :name, :string
+ end
+ end
+
+ def self.down
+ drop_table :gadgets
+ end
+end
diff --git a/vendor/plugins/acts_as_solr_reloaded/test/db/migrate/009_create_dynamic_attributes.rb b/vendor/plugins/acts_as_solr_reloaded/test/db/migrate/009_create_dynamic_attributes.rb
new file mode 100644
index 0000000..0ff8f58
--- /dev/null
+++ b/vendor/plugins/acts_as_solr_reloaded/test/db/migrate/009_create_dynamic_attributes.rb
@@ -0,0 +1,15 @@
+class CreateDynamicAttributes < ActiveRecord::Migration
+ def self.up
+ create_table :dynamic_attributes do |t|
+ t.integer :dynamicable_id
+ t.string :dynamicable_type
+ t.string :name
+ t.text :value
+ t.timestamps
+ end
+ end
+
+ def self.down
+ drop_table :dynamic_attributes
+ end
+end
diff --git a/vendor/plugins/acts_as_solr_reloaded/test/db/migrate/010_create_advertises.rb b/vendor/plugins/acts_as_solr_reloaded/test/db/migrate/010_create_advertises.rb
new file mode 100644
index 0000000..8e83ba2
--- /dev/null
+++ b/vendor/plugins/acts_as_solr_reloaded/test/db/migrate/010_create_advertises.rb
@@ -0,0 +1,13 @@
+class CreateAdvertises < ActiveRecord::Migration
+ def self.up
+ create_table :advertises do |t|
+ t.column :description, :string
+ t.timestamps
+ end
+ end
+
+ def self.down
+ drop_table :advertises
+ end
+end
+
diff --git a/vendor/plugins/acts_as_solr_reloaded/test/db/migrate/011_create_locals.rb b/vendor/plugins/acts_as_solr_reloaded/test/db/migrate/011_create_locals.rb
new file mode 100644
index 0000000..1a38bd7
--- /dev/null
+++ b/vendor/plugins/acts_as_solr_reloaded/test/db/migrate/011_create_locals.rb
@@ -0,0 +1,15 @@
+class CreateLocals < ActiveRecord::Migration
+ def self.up
+ create_table :locals do |t|
+ t.integer :localizable_id
+ t.string :localizable_type
+ t.string :latitude
+ t.string :longitude
+ t.timestamps
+ end
+ end
+
+ def self.down
+ drop_table :locals
+ end
+end
diff --git a/vendor/plugins/acts_as_solr_reloaded/test/fixtures/advertises.yml b/vendor/plugins/acts_as_solr_reloaded/test/fixtures/advertises.yml
new file mode 100644
index 0000000..1bc4226
--- /dev/null
+++ b/vendor/plugins/acts_as_solr_reloaded/test/fixtures/advertises.yml
@@ -0,0 +1,12 @@
+car:
+ id: 1
+ description: Car
+
+house:
+ id: 2
+ description: House
+
+bike:
+ id: 3
+ description: Bike
+
diff --git a/vendor/plugins/acts_as_solr_reloaded/test/fixtures/authors.yml b/vendor/plugins/acts_as_solr_reloaded/test/fixtures/authors.yml
new file mode 100644
index 0000000..c3c3571
--- /dev/null
+++ b/vendor/plugins/acts_as_solr_reloaded/test/fixtures/authors.yml
@@ -0,0 +1,9 @@
+tom_clancy:
+ id: 1
+ name: Tom Clancy
+ biography: Tom Clancy (born 1947) writes novels of adventure and espionage in the international military-industrial complex that have earned him enormous popularity in the 1980s as a creator of the "techno-thriller" genre.
+
+stephen_king:
+ id: 2
+ name: Stephen King
+ biography: Stephen King (born 1947) is a prolific and immensely popular author of horror fiction. In his works, King blends elements of the traditional gothic tale with those of the modern psychological thriller, detective, and science fiction genres.
diff --git a/vendor/plugins/acts_as_solr_reloaded/test/fixtures/books.yml b/vendor/plugins/acts_as_solr_reloaded/test/fixtures/books.yml
new file mode 100644
index 0000000..50aa446
--- /dev/null
+++ b/vendor/plugins/acts_as_solr_reloaded/test/fixtures/books.yml
@@ -0,0 +1,13 @@
+splinter_cell:
+ id: 1
+ category_id: 1
+ name: Splinter Cell
+ author: Tom Clancy
+ published_on: <%= Date.today - 1.year %>
+
+ruby:
+ id: 2
+ category_id: 2
+ name: Ruby for Dummies
+ author: Peter McPeterson
+ published_on: <%= Date.today - 2.years %>
\ No newline at end of file
diff --git a/vendor/plugins/acts_as_solr_reloaded/test/fixtures/categories.yml b/vendor/plugins/acts_as_solr_reloaded/test/fixtures/categories.yml
new file mode 100644
index 0000000..0d17418
--- /dev/null
+++ b/vendor/plugins/acts_as_solr_reloaded/test/fixtures/categories.yml
@@ -0,0 +1,7 @@
+thriller:
+ id: 1
+ name: Thriller/Novels
+
+technical:
+ id: 2
+ name: Technical Books
\ No newline at end of file
diff --git a/vendor/plugins/acts_as_solr_reloaded/test/fixtures/db_definitions/mysql.sql b/vendor/plugins/acts_as_solr_reloaded/test/fixtures/db_definitions/mysql.sql
new file mode 100644
index 0000000..aac03cb
--- /dev/null
+++ b/vendor/plugins/acts_as_solr_reloaded/test/fixtures/db_definitions/mysql.sql
@@ -0,0 +1,41 @@
+DROP DATABASE IF EXISTS `actsassolr_tests`;
+CREATE DATABASE IF NOT EXISTS `actsassolr_tests`;
+USE `actsassolr_tests`
+
+CREATE TABLE `books` (
+ `id` int(11) NOT NULL auto_increment,
+ `category_id` int(11),
+ `name` varchar(200) default NULL,
+ `author` varchar(200) default NULL,
+ PRIMARY KEY (`id`)
+);
+
+CREATE TABLE `movies` (
+ `id` int(11) NOT NULL auto_increment,
+ `name` varchar(200) default NULL,
+ `description` varchar(255) default NULL,
+ PRIMARY KEY (`id`)
+);
+
+CREATE TABLE `categories` (
+ `id` int(11) NOT NULL auto_increment,
+ `name` varchar(200) default NULL,
+ PRIMARY KEY (`id`)
+);
+
+CREATE TABLE `electronics` (
+ `id` int(11) NOT NULL auto_increment,
+ `name` varchar(200) default NULL,
+ `manufacturer` varchar(255) default NULL,
+ `features` varchar(255) default NULL,
+ `category` varchar(255) default NULL,
+ `price` varchar(20) default NULL,
+ PRIMARY KEY (`id`)
+);
+
+CREATE TABLE `authors` (
+ `id` int(11) NOT NULL auto_increment,
+ `name` varchar(200) default NULL,
+ `biography` text default NULL,
+ PRIMARY KEY (`id`)
+);
diff --git a/vendor/plugins/acts_as_solr_reloaded/test/fixtures/dynamic_attributes.yml b/vendor/plugins/acts_as_solr_reloaded/test/fixtures/dynamic_attributes.yml
new file mode 100644
index 0000000..7541237
--- /dev/null
+++ b/vendor/plugins/acts_as_solr_reloaded/test/fixtures/dynamic_attributes.yml
@@ -0,0 +1,11 @@
+DynamicAttribute:
+ id: 1
+ #name: Description
+ #value: Very cool bike
+ #advertise_id: 1
+
+DynamicAttribute:
+ id: 2
+ #name: Price
+ #value: 500
+ #advertise_id: 1
diff --git a/vendor/plugins/acts_as_solr_reloaded/test/fixtures/electronics.yml b/vendor/plugins/acts_as_solr_reloaded/test/fixtures/electronics.yml
new file mode 100644
index 0000000..c8df43b
--- /dev/null
+++ b/vendor/plugins/acts_as_solr_reloaded/test/fixtures/electronics.yml
@@ -0,0 +1,49 @@
+ipod_video:
+ id: 1
+ name: Apple 60 GB Memory iPod with Video Playback Black
+ manufacturer: Apple Computer Inc.
+ features: iTunes, Podcasts, Audiobooks
+ category: Electronics
+ price: 599.00
+ created_at: <%= (Time.now - 1.year).utc %>
+ updated_at: <%= (Time.now - 1.month).utc %>
+
+dell_monitor:
+ id: 2
+ name: Dell Widescreen UltraSharp 3007WFP
+ manufacturer: Dell, Inc
+ features: 30" TFT active matrix LCD, 2560 x 1600, .25mm dot pitch, 700:1 contrast
+ category: Electronics
+ price: 750.00
+ created_at: <%= (Time.now - 1.year).utc %>
+ updated_at: <%= (Time.now - 1.month).utc %>
+
+samsung_hd:
+ id: 3
+ name: Samsung SpinPoint P120 SP2514N - hard drive - 250 GB of Memory Storage - ATA-133
+ manufacturer: Samsung Electronics Co. Ltd.
+ features: 7200RPM, 8MB cache, IDE Ultra ATA-133
+ category: Hard Drive
+ price: 319.00
+ created_at: <%= (Time.now - 2.years).utc %>
+ updated_at: <%= (Time.now - 2.months).utc %>
+
+corsair_ram:
+ id: 4
+ name: CORSAIR XMS 2GB (2 x 1GB) 184-Pin DDR SDRAM Unbuffered DDR 400 (PC 3200) Dual Channel Kit System Memory - Retail
+ manufacturer: Corsair Microsystems Inc.
+ features: CAS latency 2, 2-3-3-6 timing, 2.75v, unbuffered, heat-spreader
+ category: Memory
+ price: 155.00
+ created_at: <%= (Time.now - 6.years).utc %>
+ updated_at: <%= (Time.now - 3.months).utc %>
+
+a_data_ram:
+ id: 5
+ name: A-DATA V-Series 1GB 184-Pin DDR SDRAM Unbuffered DDR 400 (PC 3200) System Memory - OEM
+ manufacturer: A-DATA Technology Inc.
+ features: CAS latency 3, 2.7v
+ category: Memory
+ price: 65.79
+ created_at: <%= (Time.now - 9.years).utc %>
+ updated_at: <%= (Time.now - 4.months).utc %>
diff --git a/vendor/plugins/acts_as_solr_reloaded/test/fixtures/locals.yml b/vendor/plugins/acts_as_solr_reloaded/test/fixtures/locals.yml
new file mode 100644
index 0000000..eddf888
--- /dev/null
+++ b/vendor/plugins/acts_as_solr_reloaded/test/fixtures/locals.yml
@@ -0,0 +1,9 @@
+home:
+ id: 1
+ longitude: -77.4027
+ latitude: 39.36
+
+work:
+ id: 2
+ longitude: -77.4027
+ latitude: 38.36
diff --git a/vendor/plugins/acts_as_solr_reloaded/test/fixtures/movies.yml b/vendor/plugins/acts_as_solr_reloaded/test/fixtures/movies.yml
new file mode 100644
index 0000000..33cc4df
--- /dev/null
+++ b/vendor/plugins/acts_as_solr_reloaded/test/fixtures/movies.yml
@@ -0,0 +1,9 @@
+napoleon_dynamite:
+ id: 1
+ name: Napoleon Dynamite
+ description: Cool movie about a goofy guy
+
+office_space:
+ id: 2
+ name: Office Space
+ description: Hypnotized dude loves fishing but not working
\ No newline at end of file
diff --git a/vendor/plugins/acts_as_solr_reloaded/test/fixtures/postings.yml b/vendor/plugins/acts_as_solr_reloaded/test/fixtures/postings.yml
new file mode 100644
index 0000000..834b1f2
--- /dev/null
+++ b/vendor/plugins/acts_as_solr_reloaded/test/fixtures/postings.yml
@@ -0,0 +1,10 @@
+first:
+ guid: ABC-123
+ name: Posting ABC
+ description: First posting testing primary key as string
+
+second:
+ guid: DEF-456
+ name: Posting DEF
+ description: Second posting testing primary key as string
+
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
new file mode 100644
index 0000000..d84d4c6
--- /dev/null
+++ b/vendor/plugins/acts_as_solr_reloaded/test/functional/acts_as_solr_test.rb
@@ -0,0 +1,501 @@
+# encoding: utf-8
+require "#{File.dirname(File.expand_path(__FILE__))}/../test_helper"
+
+class ActsAsSolrTest < Test::Unit::TestCase
+
+ fixtures :books, :movies, :electronics, :postings, :authors, :advertises
+
+ Document.destroy_all
+
+ DynamicAttribute.delete_all
+ Advertise.first.dynamic_attributes.create! :name => 'Description', :value => 'A very cool bike'
+ Advertise.first.dynamic_attributes.create! :name => 'Price', :value => '1000'
+
+ Local.delete_all
+ Local.create! :localizable => Advertise.find(1), :longitude => '-77.4027', :latitude => '39.36'
+ Local.create! :localizable => Advertise.find(2), :longitude => '77.4027', :latitude => '-38.36'
+
+ # Inserting new data into Solr and making sure it's getting indexed
+ def test_insert_new_data
+ assert_equal 2, Book.count_by_solr('ruby OR splinter OR bob')
+ b = Book.create(:name => "Fuze in action", :author => "Bob Bobber", :category_id => 1)
+ assert b.valid?
+ assert_equal 3, Book.count_by_solr('ruby OR splinter OR bob')
+ end
+
+ # Check the type column stored in the index isn't stemmed by SOLR. If it is stemmed,
+ # then both Post and Posting will be stored as type:Post, so a query for Posts will
+ # return Postings and vice versa
+
+ def test_insert_new_data_doesnt_stem_type
+ assert_equal 0, Post.count_by_solr('aardvark')
+ p = Posting.new :name => 'aardvark', :description => "An interesting animal"
+ p.guid = '12AB'
+ p.save!
+ assert_equal 0, Post.count_by_solr('aardvark')
+ end
+
+ def test_type_determined_from_database_if_not_explicitly_set
+ assert Post.configuration[:solr_fields][:posted_at][:type] == :date
+ end
+
+ def test_search_includes_subclasses
+ Novel.create! :name => 'Wuthering Heights', :author => 'Emily Bronte'
+ Book.create! :name => 'Jane Eyre', :author => 'Charlotte Bronte'
+ assert_equal 1, Novel.find_by_solr('Bronte').total_hits
+ assert_equal 2, Book.find_by_solr('Bronte').total_hits
+ end
+
+ # Testing basic solr search:
+ # Model.find_by_solr 'term'
+ # Note that you're able to mix free-search with fields and boolean operators
+ def test_find_by_solr_ruby
+ ['ruby', 'dummy', 'name:ruby', 'name:dummy', 'name:ruby AND author:peter',
+ 'author:peter AND ruby', 'peter dummy'].each do |term|
+ records = Book.find_by_solr term
+ assert_equal 1, records.total
+ assert_equal "Peter McPeterson", records.docs.first.author
+ assert_equal "Ruby for Dummies", records.docs.first.name
+ assert_equal ({"id" => 2,
+ "category_id" => 2,
+ "name" => "Ruby for Dummies",
+ "author" => "Peter McPeterson", "published_on" => (Date.today - 2.years), "type" => nil}), records.docs.first.attributes
+ end
+ end
+
+ # Testing basic solr search:
+ # Model.find_by_solr 'term'
+ # Note that you're able to mix free-search with fields and boolean operators
+ def test_find_by_solr_splinter
+ ['splinter', 'name:splinter', 'name:splinter AND author:clancy',
+ 'author:clancy AND splinter', 'cell tom'].each do |term|
+ records = Book.find_by_solr term
+ assert_equal 1, records.total
+ assert_equal "Splinter Cell", records.docs.first.name
+ assert_equal "Tom Clancy", records.docs.first.author
+ assert_equal ({"id" => 1, "category_id" => 1, "name" => "Splinter Cell",
+ "author" => "Tom Clancy", "published_on" => (Date.today - 1.year), "type" => nil}), records.docs.first.attributes
+ end
+ end
+
+ # Testing basic solr search:
+ # Model.find_by_solr 'term'
+ # Note that you're able to mix free-search with fields and boolean operators
+ def test_find_by_solr_ruby_or_splinter
+ ['ruby OR splinter', 'ruby OR author:tom', 'name:cell OR author:peter', 'dummy OR cell'].each do |term|
+ records = Book.find_by_solr term
+ assert_equal 2, records.total
+ end
+ end
+
+ # Testing search in indexed field methods:
+ #
+ # class Movie < ActiveRecord::Base
+ # acts_as_solr :fields => [:name, :description, :current_time]
+ #
+ # def current_time
+ # Time.now.to_s
+ # end
+ #
+ # end
+ #
+ # The method current_time above gets indexed as being part of the
+ # Movie model and it's available for search as well
+ def test_find_with_dynamic_fields
+ date = Time.now.strftime('%b %d %Y')
+ ["dynamite AND #{date}", "description:goofy AND #{date}", "goofy napoleon #{date}",
+ "goofiness #{date}"].each do |term|
+ records = Movie.find_by_solr term
+ assert_equal 1, records.total
+ assert_equal ({"id" => 1, "name" => "Napoleon Dynamite",
+ "description" => "Cool movie about a goofy guy"}), records.docs.first.attributes
+ end
+ end
+
+ # Testing basic solr search that returns just the ids instead of the objects:
+ # Model.find_id_by_solr 'term'
+ # Note that you're able to mix free-search with fields and boolean operators
+ def test_find_id_by_solr_ruby
+ ['ruby', 'dummy', 'name:ruby', 'name:dummy', 'name:ruby AND author:peter',
+ 'author:peter AND ruby'].each do |term|
+ records = Book.find_id_by_solr term
+ assert_equal 1, records.docs.size
+ assert_equal ['2'], records.docs
+ end
+ end
+
+ # Testing basic solr search that returns just the ids instead of the objects:
+ # Model.find_id_by_solr 'term'
+ # Note that you're able to mix free-search with fields and boolean operators
+ def test_find_id_by_solr_splinter
+ ['splinter', 'name:splinter', 'name:splinter AND author:clancy',
+ 'author:clancy AND splinter'].each do |term|
+ records = Book.find_id_by_solr term
+ assert_equal 1, records.docs.size
+ assert_equal ['1'], records.docs
+ end
+ end
+
+ # Testing basic solr search that returns just the ids instead of the objects:
+ # Model.find_id_by_solr 'term'
+ # Note that you're able to mix free-search with fields and boolean operators
+ def test_find_id_by_solr_ruby_or_splinter
+ ['ruby OR splinter', 'ruby OR author:tom', 'name:cell OR author:peter',
+ 'dummy OR cell'].each do |term|
+ records = Book.find_id_by_solr term
+ assert_equal 2, records.docs.size
+ assert_equal ['1','2'], records.docs
+ end
+ end
+
+ # Testing basic solr search that returns the total number of records found:
+ # Model.find_count_by_solr 'term'
+ # Note that you're able to mix free-search with fields and boolean operators
+ def test_count_by_solr
+ ['ruby', 'dummy', 'name:ruby', 'name:dummy', 'name:ruby AND author:peter',
+ 'author:peter AND ruby'].each do |term|
+ assert_equal 1, Book.count_by_solr(term), "there should only be 1 result for search: #{term}"
+ end
+ end
+
+ # Testing basic solr search that returns the total number of records found:
+ # Model.find_count_by_solr 'term'
+ # Note that you're able to mix free-search with fields and boolean operators
+ def test_count_by_solr_splinter
+ ['splinter', 'name:splinter', 'name:splinter AND author:clancy',
+ 'author:clancy AND splinter', 'author:clancy cell'].each do |term|
+ assert_equal 1, Book.count_by_solr(term)
+ end
+ end
+
+ # Testing basic solr search that returns the total number of records found:
+ # Model.find_count_by_solr 'term'
+ # Note that you're able to mix free-search with fields and boolean operators
+ def test_count_by_solr_ruby_or_splinter
+ ['ruby OR splinter', 'ruby OR author:tom', 'name:cell OR author:peter', 'dummy OR cell'].each do |term|
+ assert_equal 2, Book.count_by_solr(term)
+ end
+ end
+
+ # Testing basic solr search with additional options:
+ # Model.find_count_by_solr 'term', :limit => 10, :offset => 0
+ def test_find_with_options
+ [1,2].each do |count|
+ records = Book.find_by_solr 'ruby OR splinter', :limit => count
+ assert_equal count, records.docs.size
+ end
+ end
+
+ # Testing self.rebuild_solr_index
+ # - It makes sure the index is rebuilt after a data has been lost
+ def test_rebuild_solr_index
+ assert_equal 1, Book.count_by_solr('splinter')
+
+ Book.find(:first).solr_destroy
+ assert_equal 0, Book.count_by_solr('splinter')
+
+ Book.rebuild_solr_index
+ assert_equal 1, Book.count_by_solr('splinter')
+ end
+
+ # Testing instance methods:
+ # - solr_save
+ # - solr_destroy
+ def test_solr_save_and_solr_destroy
+ assert_equal 1, Book.count_by_solr('splinter')
+
+ Book.find(:first).solr_destroy
+ assert_equal 0, Book.count_by_solr('splinter')
+
+ Book.find(:first).solr_save
+ assert_equal 1, Book.count_by_solr('splinter')
+ end
+
+ # Testing the order of results
+ def test_find_returns_records_in_order
+ records = Book.find_by_solr 'ruby^5 OR splinter'
+ # we boosted ruby so ruby should come first
+
+ assert_equal 2, records.total
+ assert_equal 'Ruby for Dummies', records.docs.first.name
+ assert_equal 'Splinter Cell', records.docs.last.name
+ end
+
+ # Testing solr search with optional :order argument
+ def _test_with_order_option
+ records = Movie.find_by_solr 'office^5 OR goofiness'
+ assert_equal 'Hypnotized dude loves fishing but not working', records.docs.first.description
+ assert_equal 'Cool movie about a goofy guy', records.docs.last.description
+
+ records = Movie.find_by_solr 'office^5 OR goofiness', :order => 'description asc'
+ assert_equal 'Cool movie about a goofy guy', records.docs.first.description
+ assert_equal 'Hypnotized dude loves fishing but not working', records.docs.last.description
+ end
+
+ # Testing search with omitted :field_types should
+ # return the same result set as if when we use it
+ def test_omit_field_types_in_search
+ records = Electronic.find_by_solr "price:[200 TO 599.99]"
+ assert_match(/599/, records.docs.first.price)
+ assert_match(/319/, records.docs.last.price)
+
+ records = Electronic.find_by_solr "price:[200 TO 599.99]", :order => 'price asc'
+ assert_match(/319/, records.docs.first.price)
+ assert_match(/599/, records.docs.last.price)
+
+ end
+
+ # Test to make sure the result returned when no matches
+ # are found has the same structure when there are results
+ def test_returns_no_matches
+ records = Book.find_by_solr 'rubyist'
+ assert_equal [], records.docs
+ assert_equal 0, records.total
+
+ records = Book.find_id_by_solr 'rubyist'
+ assert_equal [], records.docs
+ assert_equal 0, records.total
+
+ records = Book.find_by_solr 'rubyist', :facets => {}
+ assert_equal [], records.docs
+ assert_equal 0, records.total
+ assert_equal({"facet_fields"=>[]}, records.facets)
+ end
+
+
+ # Testing the :exclude_fields option when set in the
+ # model to make sure it doesn't get indexed
+ def test_exclude_fields_option
+ records = Electronic.find_by_solr 'audiobooks OR latency'
+ assert records.docs.empty?
+ assert_equal 0, records.total
+
+ assert_nothing_raised{
+ records = Electronic.find_by_solr 'features:audiobooks'
+ assert records.docs.empty?
+ assert_equal 0, records.total
+ }
+ end
+
+ # Testing the :auto_commit option set to false in the model
+ # should not send the commit command to Solr
+ def test_auto_commit_turned_off
+ assert_equal 0, Author.count_by_solr('raymond chandler')
+
+ original_count = Author.count
+ Author.create(:name => 'Raymond Chandler', :biography => 'Writes noirish detective stories')
+
+ assert_equal original_count + 1, Author.count
+ assert_equal 0, Author.count_by_solr('raymond chandler')
+ end
+
+ # Testing models that use a different key as the primary key
+ def test_search_on_model_with_string_id_field
+ records = Posting.find_by_solr 'first^5 OR second'
+ assert_equal 2, records.total
+ assert_equal 'ABC-123', records.docs.first.guid
+ assert_equal 'DEF-456', records.docs.last.guid
+ end
+
+ # Making sure the result set is ordered correctly even on
+ # models that use a different key as the primary key
+ def test_records_in_order_on_model_with_string_id_field
+ records = Posting.find_by_solr 'first OR second^5'
+ assert_equal 2, records.total
+ assert_equal 'DEF-456', records.docs.first.guid
+ assert_equal 'ABC-123', records.docs.last.guid
+ end
+
+ # Making sure the records are added when passing a batch size
+ # to rebuild_solr_index
+ def test_using_rebuild_solr_index_with_batch
+ assert_equal 2, Movie.count_by_solr('office OR napoleon')
+ Movie.find(:all).each(&:solr_destroy)
+ assert_equal 0, Movie.count_by_solr('office OR napoleon')
+
+ Movie.rebuild_solr_index 100
+ assert_equal 2, Movie.count_by_solr('office OR napoleon')
+ end
+
+ # Making sure find_by_solr with scores actually return the scores
+ # for each individual record
+ def test_find_by_solr_with_score
+ books = Book.find_by_solr 'ruby^10 OR splinter', :scores => true
+
+ assert_equal 2, books.total
+ assert (books.max_score >= 0.3 && books.max_score <= 0.6)
+
+ books.records.each { |book| assert_not_nil book.solr_score }
+ assert (books.docs.first.solr_score >= 0.3 && books.docs.first.solr_score <= 0.6)
+ assert (books.docs.last.solr_score < books.docs.first.solr_score)
+ end
+
+ # Making sure nothing breaks when html entities are inside
+ # the content to be indexed; and on the search as well.
+ def test_index_and_search_with_html_entities
+ description = "
+ inverted exclamation mark ¡ ¡
+ ¤ currency ¤ ¤
+ ¢ cent ¢ ¢
+ £ pound £ £
+ ¥ yen ¥ ¥
+ ¦ broken vertical bar ¦ ¦
+ § section § §
+ ¨ spacing diaeresis ¨ ¨
+ © copyright © ©
+ ª feminine ordinal indicator ª ª
+ « angle quotation mark (left) « «
+ ¬ negation ¬ ¬
+ soft hyphen
+ ® registered trademark ® ®
+ ™ trademark ™ ™
+ ¯ spacing macron ¯ ¯
+ ° degree ° °
+ ± plus-or-minus ± ±
+ ² superscript 2 ² ²
+ ³ superscript 3 ³ ³
+ ´ spacing acute ´ ´
+ µ micro µ µ
+ ¶ paragraph ¶ ¶
+ · middle dot · ·
+ ¸ spacing cedilla ¸ ¸
+ ¹ superscript 1 ¹ ¹
+ º masculine ordinal indicator º º
+ » angle quotation mark (right) » »
+ ¼ fraction 1/4 ¼ ¼
+ ½ fraction 1/2 ½ ½
+ ¾ fraction 3/4 ¾ ¾
+ ¿ inverted question mark ¿ ¿
+ × multiplication × ×
+ ÷ division ÷ ÷
+ ♥ ♦ ♣ ♠"
+
+ author = Author.create(:name => "Test in Action™ - Copyright © Bob", :biography => description)
+ assert author.valid?
+ author.solr_commit
+
+ author = Author.find_by_solr 'trademark © ¾ ¡ £'
+ assert_equal 1, author.total
+ end
+
+ def test_operator_search_option
+ assert_nothing_raised {
+ books = Movie.find_by_solr "office napoleon", :operator => :or
+ assert_equal 2, books.total
+
+ books = Movie.find_by_solr "office napoleon", :operator => :and
+ assert_equal 0, books.total
+ }
+
+ assert_raise RuntimeError do
+ Movie.find_by_solr "office napoleon", :operator => :bad
+ end
+ end
+
+ # Making sure find_by_solr with scores actually return the scores
+ # for each individual record and orders them accordingly
+ def test_find_by_solr_order_by_score
+ books = Book.find_by_solr 'ruby^10 OR splinter', {:scores => true, :order => 'score asc' }
+ assert (books.docs.collect(&:solr_score).compact.size == books.docs.size), "Each book should have a score"
+ assert (books.docs.last.solr_score >= 0.3 && books.docs.last.solr_score <= 0.6)
+
+ books = Book.find_by_solr 'ruby^10 OR splinter', {:scores => true, :order => 'score desc' }
+ assert (books.docs.first.solr_score >= 0.3 && books.docs.first.solr_score <= 0.6)
+ assert (books.docs.last.solr_score < books.docs.first.solr_score)
+ end
+
+ # Search based on fields with the :date format
+ def test_indexed_date_field_format
+ movies = Movie.find_by_solr 'time_on_xml:[NOW-1DAY TO NOW]'
+ assert_equal 2, movies.total
+ end
+
+ def test_query_time_is_returned
+ results = Book.find_by_solr('ruby')
+ assert_not_nil(results.query_time)
+ assert_equal(results.query_time.class,Fixnum)
+ end
+
+ def test_should_not_index_the_record_when_offline_proc_returns_true
+ Gadget.search_disabled = true
+ gadget = Gadget.create(:name => "flipvideo mino")
+ assert_equal 0, Gadget.find_id_by_solr('flipvideo').total
+ end
+
+ def test_should_find_filtering_a_dynamic_attribute
+ records = Advertise.find_by_solr "description:bike"
+ assert_equal 1, records.total
+ end
+
+ def test_dynamic_attributes_are_faceted
+ records = Advertise.find_by_solr "Description:bike", :facets => { :fields => [:Description] }
+ expected = { "A very cool bike" => 1 }
+ assert_equal expected, records.facets['facet_fields']['Description_facet']
+ end
+
+ def test_search_is_an_alias_for_find_by_solr
+ assert_equal Advertise.find_by_solr("bike").docs, Advertise.search("bike").docs
+ end
+
+ def test_search_given_a_radius
+ records = Advertise.search "bike", :around => {: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}
+ assert_equal 1, records.total
+ end
+
+ def test_records_are_found_with_highlight
+ records = Book.find_by_solr "ruby", :highlight => { :fields => "name" }
+ assert_equal 1, records.total
+ end
+
+ def test_records_wiht_highlights_are_returned_properly
+ records = Book.find_by_solr "ruby", :highlight => { :fields => "name" }
+ expected = {"name"=>["Ruby for Dummies"]}
+ assert_equal expected, records.highlights.values.first
+ end
+
+ def test_spellcheck
+ assert_equal "ruby for dummies", Book.search("rubi for dumies").suggest
+ end
+
+ def test_mongo_mappers_documents_are_found
+ Document.new(:name => "mapper").save
+ assert_equal "mapper", Document.search("mapper").docs.first.name
+ end
+
+ def test_total_pages_is_returned_when_limit_specified
+ assert_equal 2, Posting.search("test", :limit => 1).total_pages
+ end
+
+ def test_total_pages_is_returned_when_limit_not_specified
+ assert_equal 1, Posting.search("test").total_pages
+ end
+
+ def test_current_page_is_returned
+ assert_equal 2, Posting.search("test", :limit => 1, :offset => 1).current_page
+ end
+
+ def test_current_page_1_is_returned
+ assert_equal 1, Posting.search("test").current_page
+ end
+
+ def test_current_page_1_is_returned_when_no_records_found
+ assert_equal 1, Posting.search("nothing").current_page
+ end
+
+ def test_page_parameter_is_accepted
+ assert_equal 2, Posting.search("test", :limit => 1, :page => 2).current_page
+ end
+
+ def test_per_page_parameter_is_accepted
+ assert_equal 1, Posting.search("test", :per_page => 1).per_page
+ end
+end
diff --git a/vendor/plugins/acts_as_solr_reloaded/test/functional/association_indexing_test.rb b/vendor/plugins/acts_as_solr_reloaded/test/functional/association_indexing_test.rb
new file mode 100644
index 0000000..c0acacf
--- /dev/null
+++ b/vendor/plugins/acts_as_solr_reloaded/test/functional/association_indexing_test.rb
@@ -0,0 +1,37 @@
+require File.join(File.dirname(__FILE__), '../test_helper')
+
+class AssociationIndexingTest < Test::Unit::TestCase
+
+ fixtures :categories, :books
+
+ # Testing the association indexing with has_many:
+ #
+ # class Category < ActiveRecord::Base
+ # has_many :books
+ # acts_as_solr :include => [:books]
+ # end
+ #
+ # Note that some of the search terms below are from the 'books'
+ # table, but get indexed as being a part of Category
+ def test_search_on_fields_in_has_many_association
+ ['thriller', 'novel', 'splinter', 'clancy', 'tom clancy thriller'].each do |term|
+ assert_equal 1, Category.count_by_solr(term), "expected one result: #{term}"
+ end
+ end
+
+ # Testing the association indexing with belongs_to:
+ #
+ # class Book < ActiveRecord::Base
+ # belongs_to :category
+ # acts_as_solr :include => [:category]
+ # end
+ #
+ # Note that some of the search terms below are from the 'categories'
+ # table, but get indexed as being a part of Book
+ def test_search_on_fields_in_belongs_to_association
+ ['splinter', 'clancy', 'tom clancy thriller', 'splinter novel'].each do |term|
+ assert_equal 1, Book.count_by_solr(term), "expected one result: #{term}"
+ end
+ end
+
+end
diff --git a/vendor/plugins/acts_as_solr_reloaded/test/functional/faceted_search_test.rb b/vendor/plugins/acts_as_solr_reloaded/test/functional/faceted_search_test.rb
new file mode 100644
index 0000000..582ce0a
--- /dev/null
+++ b/vendor/plugins/acts_as_solr_reloaded/test/functional/faceted_search_test.rb
@@ -0,0 +1,163 @@
+require File.join(File.dirname(__FILE__), '../test_helper')
+
+class FacetedSearchTest < Test::Unit::TestCase
+
+ fixtures :electronics
+
+ # The tests below are for faceted search, but make sure you setup
+ # the fields on your model you'd like to index as a facet field:
+ #
+ # class Electronic < ActiveRecord::Base
+ # acts_as_solr :facets => [:category, :manufacturer]
+ # end
+ #
+ # A basic faceted search using just one facet field
+ def test_faceted_search_basic
+ records = Electronic.find_by_solr "memory", :facets => {:fields =>[:category]}
+ assert_equal 4, records.docs.size
+ assert_match /Apple 60 GB Memory iPod/, records.docs.first.name
+ assert_equal({"category_facet" => {"Electronics" => 1,
+ "Memory" => 2,
+ "Hard Drive" => 1}},
+ records.facets['facet_fields'])
+ end
+
+ # Making sure the empty result returned what we expected
+ def test_faceted_search_no_matches
+ records = Electronic.find_by_solr "not found", :facets => { :fields => [:category]}
+ assert_equal [], records.docs
+ assert_equal [], records.facets['facet_fields']
+ end
+
+ # A basic faceted search using multiple facet fields
+ def test_faceted_search_multiple_fields
+ records = Electronic.find_by_solr "memory", :facets => {:fields =>[:category, :manufacturer]}
+ assert_equal 4, records.docs.size
+ assert_equal({"category_facet" => {"Electronics" => 1,
+ "Memory" => 2,
+ "Hard Drive" => 1},
+ "manufacturer_facet" => {"Dell, Inc" => 0,
+ "Samsung Electronics Co. Ltd." => 1,
+ "Corsair Microsystems Inc." => 1,
+ "A-DATA Technology Inc." => 1,
+ "Apple Computer Inc." => 1}}, records.facets['facet_fields'])
+ end
+
+ # A basic faceted search using facet queries to get counts.
+ # Here are the facets search query meaning:
+ # "price:[* TO 200]" - Price up to 200
+ # "price:[200 TO 500]" - Price from 200 to 500
+ # "price:[500 TO *]" - Price higher than 500
+ def test_facet_search_with_query
+ records = Electronic.find_by_solr "memory", :facets => {:query => ["price:[* TO 200.00]",
+ "price:[200.00 TO 500.00]",
+ "price:[500.00 TO *]"]}
+ assert_equal 4, records.docs.size
+ assert_equal({"facet_queries" => {"price_rf:[* TO 200.00]"=>2,
+ "price_rf:[200.00 TO 500.00]"=>1,
+ "price_rf:[500.00 TO *]"=>1},
+ "facet_fields" => {}, "facet_dates" => {}}, records.facets)
+ end
+
+ # Faceted search specifying the query and fields
+ def test_facet_search_with_query_and_field
+ records = Electronic.find_by_solr "memory", :facets => {:query => ["price:[* TO 200.00]",
+ "price:[200.00 TO 500.00]",
+ "price:[500.00 TO *]"],
+ :fields => [:category, :manufacturer]}
+
+ q = records.facets["facet_queries"]
+ assert_equal 2, q["price_rf:[* TO 200.00]"]
+ assert_equal 1, q["price_rf:[500.00 TO *]"]
+ assert_equal 1, q["price_rf:[200.00 TO 500.00]"]
+
+ f = records.facets["facet_fields"]
+ assert_equal 1, f["category_facet"]["Electronics"]
+ assert_equal 2, f["category_facet"]["Memory"]
+ assert_equal 1, f["category_facet"]["Hard Drive"]
+ assert_equal 1, f["manufacturer_facet"]["Samsung Electronics Co. Ltd."]
+ assert_equal 1, f["manufacturer_facet"]["Corsair Microsystems Inc."]
+ assert_equal 1, f["manufacturer_facet"]["A-DATA Technology Inc."]
+ assert_equal 1, f["manufacturer_facet"]["Apple Computer Inc."]
+ end
+
+ # Faceted searches with :sort and :zeros options turned on/off
+ def test_faceted_search_using_zero_and_sort
+ records = Electronic.find_by_solr "memory", :facets => {:fields =>[:category]}
+ assert_equal({"category_facet"=>{"Electronics"=>1, "Memory"=>2, "Hard Drive"=>1}}, records.facets['facet_fields'])
+
+ records = Electronic.find_by_solr "memory", :facets => {:sort => true, :fields =>[:category]}
+ assert_equal({"category_facet"=>{"Memory"=>2, "Electronics"=>1, "Hard Drive"=>1}}, records.facets['facet_fields'])
+
+ records = Electronic.find_by_solr "memory", :facets => {:fields =>[:manufacturer]}
+ assert_equal({"manufacturer_facet" => {"Dell, Inc" => 0,
+ "Samsung Electronics Co. Ltd." => 1,
+ "Corsair Microsystems Inc." => 1,
+ "A-DATA Technology Inc." => 1,
+ "Apple Computer Inc." => 1}}, records.facets['facet_fields'])
+
+ records = Electronic.find_by_solr "memory", :facets => {:zeros => false, :fields =>[:manufacturer]}
+ assert_equal({"manufacturer_facet" => {"Samsung Electronics Co. Ltd." => 1,
+ "Corsair Microsystems Inc." => 1,
+ "A-DATA Technology Inc." => 1,
+ "Apple Computer Inc." => 1}}, records.facets['facet_fields'])
+ end
+
+ # Faceted search with 'drill-down' option being passed.
+ # The :browse option receives the argument in the format:
+ # "facet_field:term". You can drill-down to as many
+ # facet fields as you like
+ def test_faceted_search_with_drill_down
+ records = Electronic.find_by_solr "memory", :facets => {:fields =>[:category]}
+ assert_equal 4, records.docs.size
+ assert_equal({"category_facet"=>{"Electronics"=>1, "Memory"=>2, "Hard Drive"=>1}}, records.facets['facet_fields'])
+
+ records = Electronic.find_by_solr "memory", :facets => {:fields =>[:category],
+ :browse => "category:Memory",
+ :zeros => false}
+ assert_equal 2, records.docs.size
+ assert_equal({"category_facet"=>{"Memory"=>2}}, records.facets['facet_fields'])
+ end
+
+ def test_faceted_search_with_dates
+ records = Electronic.find_by_solr "memory", :facets => {:dates => {:fields => [:created_at, :updated_at],
+ :start => (Date.today - 7.years).strftime("%Y-%m-%dT%H:%M:%SZ"), :end => Date.today.strftime("%Y-%m-%dT%H:%M:%SZ"), :gap => '+1YEAR', :other => :all}}
+
+ assert_equal 4, records.docs.size
+
+ assert_equal 0, records.facets["facet_dates"]["created_at_d"]["after"]
+ assert_equal 1, records.facets["facet_dates"]["created_at_d"]["before"]
+ assert_equal 3, records.facets["facet_dates"]["created_at_d"]["between"]
+
+ assert_equal 0, records.facets["facet_dates"]["updated_at_d"]["after"]
+ assert_equal 0, records.facets["facet_dates"]["updated_at_d"]["before"]
+ assert_equal 4, records.facets["facet_dates"]["updated_at_d"]["between"]
+ end
+
+ def test_faceted_search_with_dates_filter
+ records = Electronic.find_by_solr "memory", :facets => {:dates => {:filter => ["updated_at:[#{(Date.today - 3.months).strftime("%Y-%m-%dT%H:%M:%SZ")} TO NOW-1MONTH/DAY]"]}}
+
+ assert_equal 2, records.docs.size
+
+ records.docs.each { |r|
+ assert r.updated_at >= (Date.today - 3.month)
+ assert r.updated_at <= (Date.today - 1.month)
+ }
+ end
+
+ def test_faceted_search_with_dates_filter_and_facets
+ # this is a very contrived example but gives us data to validate
+ records = Electronic.find_by_solr "memory", :facets => {:dates => {:filter => ["updated_at:[#{(Date.today - 3.months).strftime("%Y-%m-%dT%H:%M:%SZ")} TO NOW-1MONTH/DAY]"],
+ :fields => [:created_at, :updated_at], :start => 'NOW-2MONTHS/DAY', :end => 'NOW-1MONTH/DAY', :gap => '+1MONTH', :other => :all}}
+
+ assert_equal 2, records.docs.size
+
+ assert_equal 0, records.facets["facet_dates"]["created_at_d"]["after"]
+ assert_equal 2, records.facets["facet_dates"]["created_at_d"]["before"]
+ assert_equal 0, records.facets["facet_dates"]["created_at_d"]["between"]
+
+ assert_equal 0, records.facets["facet_dates"]["updated_at_d"]["after"]
+ assert_equal 1, records.facets["facet_dates"]["updated_at_d"]["before"]
+ assert_equal 1, records.facets["facet_dates"]["updated_at_d"]["between"]
+ end
+end
diff --git a/vendor/plugins/acts_as_solr_reloaded/test/functional/multi_solr_search_test.rb b/vendor/plugins/acts_as_solr_reloaded/test/functional/multi_solr_search_test.rb
new file mode 100644
index 0000000..4c500c0
--- /dev/null
+++ b/vendor/plugins/acts_as_solr_reloaded/test/functional/multi_solr_search_test.rb
@@ -0,0 +1,57 @@
+require File.join(File.dirname(__FILE__), '../test_helper')
+
+class ActsAsSolrTest < Test::Unit::TestCase
+
+ fixtures :books, :movies
+
+ # Testing the multi_solr_search with the returning results being objects
+ def test_multi_solr_search_return_objects
+ records = Book.multi_solr_search "Napoleon OR Tom", :models => [Movie], :results_format => :objects
+ assert_equal 2, records.total
+ classes = records.docs.map {|d| d.class}
+ assert classes.include?(Book)
+ assert classes.include?(Movie)
+ end
+
+ # Testing the multi_solr_search with the returning results being ids
+ def test_multi_solr_search_return_ids
+ records = Book.multi_solr_search "Napoleon OR Tom", :models => [Movie], :results_format => :ids
+ assert_equal 2, records.total
+ assert records.docs.include?({"id" => "Movie:1"})
+ assert records.docs.include?({"id" => "Book:1"})
+ end
+
+ # Testing the multi_solr_search with multiple models
+ def test_multi_solr_search_multiple_models
+ # TODO: Generalize me
+ ActsAsSolr::Post.execute(Solr::Request::Delete.new(:query => 'type_s:Author AND NOT id:"Author:1" AND NOT id:"Author:2"'))
+ ActsAsSolr::Post.execute(Solr::Request::Delete.new(:query => 'type_s:Book AND NOT id:"Book:1" AND NOT id:"Book:2"'))
+ ActsAsSolr::Post.execute(Solr::Request::Commit.new)
+
+ records = Book.multi_solr_search "Napoleon OR Tom OR Thriller", :models => [Movie, Category], :results_format => :ids
+ assert_equal 3, records.total
+ assert records.docs.include?({"id" => "Category:1"})
+ assert records.docs.include?({"id" =>"Book:1"})
+ assert records.docs.include?({"id" => "Movie:1"})
+ end
+
+ # Testing empty result set format
+ def test_returns_no_matches
+ records = Book.multi_solr_search "not found", :models => [Movie, Category]
+ assert_equal [], records.docs
+ assert_equal 0, records.total
+ end
+
+ def test_search_on_empty_string_does_not_return_nil
+ records = Book.multi_solr_search('', :models => [Movie, Category])
+ assert_not_nil records
+ assert_equal [], records.docs
+ assert_equal 0, records.total
+ end
+
+ def test_search_with_score_should_set_score
+ records = Book.multi_solr_search "Napoleon OR Tom", :models => [Movie], :results_format => :objects, :scores => true
+ assert records.docs.first.solr_score.is_a?(Float)
+ assert records.docs.last.solr_score.is_a?(Float)
+ end
+end
diff --git a/vendor/plugins/acts_as_solr_reloaded/test/models/advertise.rb b/vendor/plugins/acts_as_solr_reloaded/test/models/advertise.rb
new file mode 100644
index 0000000..1bbc326
--- /dev/null
+++ b/vendor/plugins/acts_as_solr_reloaded/test/models/advertise.rb
@@ -0,0 +1,6 @@
+# Table fields for 'advertises'
+# - id
+
+class Advertise < ActiveRecord::Base
+ acts_as_solr :dynamic_attributes => true, :spatial => true
+end
diff --git a/vendor/plugins/acts_as_solr_reloaded/test/models/author.rb b/vendor/plugins/acts_as_solr_reloaded/test/models/author.rb
new file mode 100644
index 0000000..6ce9180
--- /dev/null
+++ b/vendor/plugins/acts_as_solr_reloaded/test/models/author.rb
@@ -0,0 +1,10 @@
+# Table fields for 'movies'
+# - id
+# - name
+# - biography
+
+class Author < ActiveRecord::Base
+
+ acts_as_solr :auto_commit => false
+
+end
\ No newline at end of file
diff --git a/vendor/plugins/acts_as_solr_reloaded/test/models/book.rb b/vendor/plugins/acts_as_solr_reloaded/test/models/book.rb
new file mode 100644
index 0000000..18c416d
--- /dev/null
+++ b/vendor/plugins/acts_as_solr_reloaded/test/models/book.rb
@@ -0,0 +1,10 @@
+# Table fields for 'books'
+# - id
+# - category_id
+# - name
+# - author
+
+class Book < ActiveRecord::Base
+ belongs_to :category
+ acts_as_solr :include => [:category]
+end
\ No newline at end of file
diff --git a/vendor/plugins/acts_as_solr_reloaded/test/models/category.rb b/vendor/plugins/acts_as_solr_reloaded/test/models/category.rb
new file mode 100644
index 0000000..09e2fa4
--- /dev/null
+++ b/vendor/plugins/acts_as_solr_reloaded/test/models/category.rb
@@ -0,0 +1,8 @@
+# Table fields for 'categories'
+# - id
+# - name
+
+class Category < ActiveRecord::Base
+ has_many :books
+ acts_as_solr :include => [:books]
+end
\ No newline at end of file
diff --git a/vendor/plugins/acts_as_solr_reloaded/test/models/document.rb b/vendor/plugins/acts_as_solr_reloaded/test/models/document.rb
new file mode 100644
index 0000000..4ce56ef
--- /dev/null
+++ b/vendor/plugins/acts_as_solr_reloaded/test/models/document.rb
@@ -0,0 +1,6 @@
+class Document
+ include MongoMapper::Document
+ include ActsAsSolr::MongoMapper
+ key :name, String
+ acts_as_solr
+end
\ No newline at end of file
diff --git a/vendor/plugins/acts_as_solr_reloaded/test/models/dynamic_attribute.rb b/vendor/plugins/acts_as_solr_reloaded/test/models/dynamic_attribute.rb
new file mode 100644
index 0000000..ebc59db
--- /dev/null
+++ b/vendor/plugins/acts_as_solr_reloaded/test/models/dynamic_attribute.rb
@@ -0,0 +1,7 @@
+# Table fields for 'dynamic attributes'
+# - id
+# - name
+# - value
+
+class DynamicAttribute < ActiveRecord::Base
+end
diff --git a/vendor/plugins/acts_as_solr_reloaded/test/models/electronic.rb b/vendor/plugins/acts_as_solr_reloaded/test/models/electronic.rb
new file mode 100644
index 0000000..52f25f2
--- /dev/null
+++ b/vendor/plugins/acts_as_solr_reloaded/test/models/electronic.rb
@@ -0,0 +1,25 @@
+# Table fields for 'electronics'
+# - id
+# - name
+# - manufacturer
+# - features
+# - category
+# - price
+# - created_on
+
+class Electronic < ActiveRecord::Base
+ acts_as_solr do
+ {
+ :facets => [:category, :manufacturer],
+ :fields => [:name, :manufacturer, :features, :category, {:created_at => :date}, {:updated_at => :date}, {:price => {:type => :range_float, :boost => 10.0}}],
+ :boost => 5.0,
+ :exclude_fields => [:features]
+ }
+ end
+
+ # The following example would also convert the :price field type to :range_float
+ #
+ # acts_as_solr :facets => [:category, :manufacturer],
+ # :fields => [:name, :manufacturer, :features, :category, {:price => :range_float}],
+ # :boost => 5.0
+end
diff --git a/vendor/plugins/acts_as_solr_reloaded/test/models/gadget.rb b/vendor/plugins/acts_as_solr_reloaded/test/models/gadget.rb
new file mode 100644
index 0000000..4782176
--- /dev/null
+++ b/vendor/plugins/acts_as_solr_reloaded/test/models/gadget.rb
@@ -0,0 +1,9 @@
+class Gadget < ActiveRecord::Base
+ cattr_accessor :search_disabled
+
+ acts_as_solr :offline => proc {|record| Gadget.search_disabled?}, :format => :ids
+
+ def self.search_disabled?
+ search_disabled
+ end
+end
\ No newline at end of file
diff --git a/vendor/plugins/acts_as_solr_reloaded/test/models/local.rb b/vendor/plugins/acts_as_solr_reloaded/test/models/local.rb
new file mode 100644
index 0000000..e2964cc
--- /dev/null
+++ b/vendor/plugins/acts_as_solr_reloaded/test/models/local.rb
@@ -0,0 +1,7 @@
+# Table fields for 'movies'
+# - id
+# - longitude
+# - latitude
+
+class Local < ActiveRecord::Base
+end
diff --git a/vendor/plugins/acts_as_solr_reloaded/test/models/movie.rb b/vendor/plugins/acts_as_solr_reloaded/test/models/movie.rb
new file mode 100644
index 0000000..e1d4dab
--- /dev/null
+++ b/vendor/plugins/acts_as_solr_reloaded/test/models/movie.rb
@@ -0,0 +1,17 @@
+# Table fields for 'movies'
+# - id
+# - name
+# - description
+
+class Movie < ActiveRecord::Base
+ acts_as_solr :additional_fields => [:current_time, {:time_on_xml => :date}]
+
+ def current_time
+ Time.now.to_s
+ end
+
+ def time_on_xml
+ Time.now
+ end
+
+end
\ No newline at end of file
diff --git a/vendor/plugins/acts_as_solr_reloaded/test/models/novel.rb b/vendor/plugins/acts_as_solr_reloaded/test/models/novel.rb
new file mode 100644
index 0000000..09fad52
--- /dev/null
+++ b/vendor/plugins/acts_as_solr_reloaded/test/models/novel.rb
@@ -0,0 +1,2 @@
+class Novel < Book
+end
\ No newline at end of file
diff --git a/vendor/plugins/acts_as_solr_reloaded/test/models/post.rb b/vendor/plugins/acts_as_solr_reloaded/test/models/post.rb
new file mode 100644
index 0000000..4388aaa
--- /dev/null
+++ b/vendor/plugins/acts_as_solr_reloaded/test/models/post.rb
@@ -0,0 +1,3 @@
+class Post < ActiveRecord::Base
+ acts_as_solr
+end
\ No newline at end of file
diff --git a/vendor/plugins/acts_as_solr_reloaded/test/models/posting.rb b/vendor/plugins/acts_as_solr_reloaded/test/models/posting.rb
new file mode 100644
index 0000000..f71070a
--- /dev/null
+++ b/vendor/plugins/acts_as_solr_reloaded/test/models/posting.rb
@@ -0,0 +1,11 @@
+# Table fields for 'movies'
+# - guid
+# - name
+# - description
+
+class Posting < ActiveRecord::Base
+
+ set_primary_key 'guid'
+ acts_as_solr({},{:primary_key_field => 'pk_s'})
+
+end
\ No newline at end of file
diff --git a/vendor/plugins/acts_as_solr_reloaded/test/test_helper.rb b/vendor/plugins/acts_as_solr_reloaded/test/test_helper.rb
new file mode 100644
index 0000000..f23e987
--- /dev/null
+++ b/vendor/plugins/acts_as_solr_reloaded/test/test_helper.rb
@@ -0,0 +1,70 @@
+require 'rubygems'
+require 'test/unit'
+require 'active_record'
+require 'active_record/fixtures'
+
+require 'ruby-debug'
+
+begin
+ require 'active_support/test_case'
+rescue
+end
+
+require 'mongo_mapper'
+
+MongoMapper.database = "acts_as_solr_reloaded-test"
+
+RAILS_ROOT = File.dirname(__FILE__) unless defined? RAILS_ROOT
+RAILS_ENV = 'test' unless defined? RAILS_ENV
+ENV["RAILS_ENV"] = "test"
+ENV["ACTS_AS_SOLR_TEST"] = "true"
+
+require File.expand_path(File.dirname(__FILE__) + '/../lib/acts_as_solr')
+require File.expand_path(File.dirname(__FILE__) + '/../config/solr_environment.rb')
+
+# Load Models
+models_dir = File.join(File.dirname( __FILE__ ), 'models')
+require "#{models_dir}/book.rb"
+Dir[ models_dir + '/*.rb'].each { |m| require m }
+
+if defined?(ActiveSupport::TestCase)
+ class ActiveSupport::TestCase
+ include ActiveRecord::TestFixtures
+ self.fixture_path = File.dirname(__FILE__) + "/fixtures/"
+ end unless ActiveSupport::TestCase.respond_to?(:fixture_path=)
+else
+ Test::Unit::TestCase.fixture_path = File.dirname(__FILE__) + "/fixtures/"
+end
+
+class Test::Unit::TestCase
+ def self.fixtures(*table_names)
+ fixture_path = defined?(ActiveSupport::TestCase) ? ActiveSupport::TestCase.fixture_path : Test::Unit::TestCase.fixture_path
+ if block_given?
+ Fixtures.create_fixtures(fixture_path, table_names) { yield }
+ else
+ Fixtures.create_fixtures(fixture_path, table_names)
+ end
+ table_names.each do |table_name|
+ clear_from_solr(table_name)
+ klass = instance_eval table_name.to_s.capitalize.singularize
+ klass.find(:all).each{|content| content.solr_save}
+ end
+
+ clear_from_solr(:novels)
+ end
+
+ private
+ def self.clear_from_solr(table_name)
+ ActsAsSolr::Post.execute(Solr::Request::Delete.new(:query => "type_s:#{table_name.to_s.capitalize.singularize}"))
+ end
+end
+
+class Rails
+ def self.root
+ RAILS_ROOT
+ end
+
+ def self.env
+ RAILS_ENV
+ end
+end
diff --git a/vendor/plugins/acts_as_solr_reloaded/test/unit/acts_methods_shoulda.rb b/vendor/plugins/acts_as_solr_reloaded/test/unit/acts_methods_shoulda.rb
new file mode 100644
index 0000000..0dfd5e9
--- /dev/null
+++ b/vendor/plugins/acts_as_solr_reloaded/test/unit/acts_methods_shoulda.rb
@@ -0,0 +1,110 @@
+require File.expand_path("#{File.dirname(__FILE__)}/test_helper")
+
+class ActsMethodsTest < Test::Unit::TestCase
+ class Model
+ attr_accessor :birthdate
+
+ def initialize(birthdate)
+ @birthdate = birthdate
+ end
+
+ def self.configuration
+ @configuration ||= {:solr_fields => {}}
+ end
+
+ def self.columns_hash=(columns_hash)
+ @columns_hash = columns_hash
+ end
+
+ def self.columns_hash
+ @columns_hash
+ end
+
+ def [](key)
+ @birthday
+ end
+
+ self.extend ActsAsSolr::ActsMethods
+ end
+
+ class Abstract
+ def self.acts_as_taggable_on(what)
+ @_taggable = what.eql?(:tags)
+ end
+
+ def self.taggable?
+ @_taggable
+ end
+ extend ActsAsSolr::ActsMethods
+ end
+
+ class Taggable < Abstract
+ begin
+ acts_as_solr :taggable => true
+ rescue
+ end
+ end
+
+ class NotTaggable < Abstract
+ end
+
+ class Mapper
+ include MongoMapper::Document
+ include ActsAsSolr::MongoMapper
+ key :value1, String
+ acts_as_solr
+ end
+
+ should "define the model as taggable if taggable is true" do
+ assert Taggable.taggable?
+ end
+
+ should "not define the model as taggable if taggable is not true" do
+ assert !NotTaggable.taggable?
+ end
+
+ should "define the type of a MongoMapper document id as text" do
+ assert_equal :text, Mapper.configuration[:solr_fields][:_id][:type]
+ end
+
+ should "recognize the type String of a MongoMapper key as text" do
+ assert_equal :text, Mapper.configuration[:solr_fields][:value1][:type]
+ end
+
+ context "when getting field values" do
+ setup do
+ Model.columns_hash = {"birthdate" => stub("column", :type => :date)}
+ Model.send(:get_field_value, :birthdate)
+ end
+
+ should "define an accessor methods for a solr converted value" do
+ assert Model.instance_methods.include?("birthdate_for_solr")
+ end
+
+ context "for date types" do
+ setup do
+ @model = Model.new(Date.today)
+ end
+
+ should "return nil when field is nil" do
+ @model.birthdate = nil
+ assert_nil @model.birthdate_for_solr
+ end
+
+ should "return the formatted date" do
+ assert_equal Date.today.strftime("%Y-%m-%dT%H:%M:%SZ"), @model.birthdate_for_solr
+ end
+ end
+
+ context "for timestamp types" do
+ setup do
+ @now = Time.now
+ @model = Model.new(@now)
+ end
+
+ should "return a formatted timestamp string for timestamps" do
+ assert_equal @now.utc.strftime("%Y-%m-%dT%H:%M:%SZ"), @model.birthdate_for_solr
+ end
+ end
+ end
+end
diff --git a/vendor/plugins/acts_as_solr_reloaded/test/unit/class_methods_shoulda.rb b/vendor/plugins/acts_as_solr_reloaded/test/unit/class_methods_shoulda.rb
new file mode 100644
index 0000000..7235d55
--- /dev/null
+++ b/vendor/plugins/acts_as_solr_reloaded/test/unit/class_methods_shoulda.rb
@@ -0,0 +1,85 @@
+require File.expand_path("#{File.dirname(__FILE__)}/test_helper")
+
+class User
+ attr_accessor :name, :id
+ def self.find(*args)
+ @paul ||= User.new
+ @paul.name = "Paul"
+ @paul.id = 1
+ @paul
+ end
+
+ def self.find_by_id(id)
+ find
+ end
+
+ def self.primary_key
+ "id"
+ end
+end
+
+class ClassMethodsTest < Test::Unit::TestCase
+ include ActsAsSolr::ClassMethods
+
+ def solr_configuration
+ @solr_configuration ||= {:type_field => "type_t", :primary_key_field => "id"}
+ end
+
+ context "when multi-searching" do
+ setup do
+ stubs(:name).returns("User")
+ end
+
+ should "include the type field in the query" do
+ expects(:parse_query).with("name:paul", {:results_format => :objects}, "AND (type_t:User)")
+ multi_solr_search("name:paul")
+ end
+
+ should "add all models in the query" do
+ expects(:parse_query).with("name:paul", {:results_format => :objects, :models => ["Movie", "DVD"]}, "AND (type_t:User OR type_t:Movie OR type_t:DVD)")
+ multi_solr_search("name:paul", :models => ["Movie", "DVD"])
+ end
+
+ should "return an empty result set if no data was returned" do
+ stubs(:parse_query).returns(nil)
+ result = multi_solr_search("name:paul")
+ assert_equal 0, result.docs.size
+ end
+
+ should "return an empty result set if no results were found" do
+ stubs(:parse_query).returns(stub(:total_hits => 0, :hits => []))
+ result = multi_solr_search("name:paul")
+ assert_equal 0, result.docs.size
+ end
+
+ context "with results" do
+ should "find the objects in the database" do
+ stubs(:parse_query).returns(stub(:total_hits => 1, :hits => ["score" => 0.12956427, "id" => ["User:1"]]))
+ result = multi_solr_search("name:paul")
+
+ assert_equal(User.find, result.docs.first)
+ assert_equal 1, result.docs.size
+ end
+
+ context "when requesting ids" do
+ should "return only ids" do
+ stubs(:parse_query).returns(stub(:total_hits => 1, :hits => ["score" => 0.12956427, "id" => ["User:1"]]))
+ result = multi_solr_search("name:paul", :results_format => :ids)
+ assert_equal "User:1", result.docs.first["id"]
+ end
+ end
+
+ context "with scores" do
+ setup do
+ solr_configuration[:primary_key_field] = nil
+ end
+
+ should "add an accessor with the solr score" do
+ stubs(:parse_query).returns(stub(:total_hits => 1, :hits => ["score" => 0.12956427, "id" => ["User:1"]]))
+ result = multi_solr_search("name:paul", :scores => true)
+ assert_equal 0.12956427, result.docs.first.solr_score
+ end
+ end
+ end
+ end
+end
\ No newline at end of file
diff --git a/vendor/plugins/acts_as_solr_reloaded/test/unit/common_methods_shoulda.rb b/vendor/plugins/acts_as_solr_reloaded/test/unit/common_methods_shoulda.rb
new file mode 100644
index 0000000..fd70ed3
--- /dev/null
+++ b/vendor/plugins/acts_as_solr_reloaded/test/unit/common_methods_shoulda.rb
@@ -0,0 +1,128 @@
+require File.expand_path("#{File.dirname(__FILE__)}/test_helper")
+
+class CommonMethodsTest < Test::Unit::TestCase
+ include ActsAsSolr::CommonMethods
+
+ class Mongo
+ include MongoMapper::Document
+ include ActsAsSolr::MongoMapper
+ acts_as_solr
+
+ def id
+ '4b5e0119f3a4b02902000001'
+ end
+ end
+
+ class << self
+ def primary_key
+ "id"
+ end
+ end
+
+ def id
+ 10
+ end
+
+ context "when determining the field type" do
+ setup do
+ end
+
+ should "return i for an integer" do
+ assert_equal "i", get_solr_field_type(:integer)
+ end
+
+ should "return f for a float" do
+ assert_equal "f", get_solr_field_type(:float)
+ end
+
+ should "return b for a boolean" do
+ assert_equal "b", get_solr_field_type(:boolean)
+ end
+
+ should "return s for a string" do
+ assert_equal "s", get_solr_field_type(:string)
+ end
+
+ should "return t for a text" do
+ assert_equal "t", get_solr_field_type(:text)
+ end
+
+ should "return d for a date" do
+ assert_equal "d", get_solr_field_type(:date)
+ end
+
+ should "return ri for a range_integer" do
+ assert_equal "ri", get_solr_field_type(:range_integer)
+ end
+
+ should "return rf for a range_float" do
+ assert_equal "rf", get_solr_field_type(:range_float)
+ end
+
+ should "return facet for a facet field" do
+ assert_equal "facet", get_solr_field_type(:facet)
+ end
+
+ should "return the string if one was given as an argument" do
+ assert_equal "string", get_solr_field_type("string")
+ end
+
+ should "raise an error if invalid field type was specified" do
+ assert_raise(RuntimeError) {get_solr_field_type(:something)}
+ end
+
+ should "raise an error if argument is not symbol or string" do
+ assert_raise(RuntimeError) {get_solr_field_type(123)}
+ end
+ end
+
+ context "when determining a default value for a field when it's nil" do
+ should "return 0.00 for a float" do
+ assert_equal 0.00, set_value_if_nil("f")
+ assert_equal 0.00, set_value_if_nil(:float)
+ assert_equal 0.00, set_value_if_nil("rf")
+ assert_equal 0.00, set_value_if_nil(:range_float)
+ end
+
+ should "return 0 for an integer" do
+ assert_equal 0, set_value_if_nil(:integer)
+ assert_equal 0, set_value_if_nil(:range_integer)
+ assert_equal 0, set_value_if_nil("i")
+ assert_equal 0, set_value_if_nil("ri")
+ end
+
+ should "return false for a boolean" do
+ assert_equal "false", set_value_if_nil(:boolean)
+ assert_equal "false", set_value_if_nil("b")
+ end
+
+ should "return empty string for strings and text" do
+ assert_equal "", set_value_if_nil(:string)
+ assert_equal "", set_value_if_nil(:text)
+ assert_equal "", set_value_if_nil("t")
+ assert_equal "", set_value_if_nil("s")
+ end
+
+ should "return an empty string for a date" do
+ assert_equal "", set_value_if_nil(:date)
+ assert_equal "", set_value_if_nil("d")
+ end
+
+ should "return an empty string for everything else" do
+ assert_equal "", set_value_if_nil("something")
+ end
+ end
+
+ context "when determining the record id" do
+ context "on ActiveRecord" do
+ should "return the primary key value" do
+ assert_equal 10, record_id(self)
+ end
+ end
+ context "on MongoMapper" do
+ should "return the id value" do
+ assert_equal '4b5e0119f3a4b02902000001', record_id(Mongo.new)
+ end
+ end
+ end
+end
\ No newline at end of file
diff --git a/vendor/plugins/acts_as_solr_reloaded/test/unit/instance_methods_shoulda.rb b/vendor/plugins/acts_as_solr_reloaded/test/unit/instance_methods_shoulda.rb
new file mode 100644
index 0000000..a1c7f5b
--- /dev/null
+++ b/vendor/plugins/acts_as_solr_reloaded/test/unit/instance_methods_shoulda.rb
@@ -0,0 +1,372 @@
+require File.expand_path("#{File.dirname(__FILE__)}/test_helper")
+module Solr; end
+
+class InstanceMethodsTest < Test::Unit::TestCase
+
+ context "With a Solr record instance" do
+ setup do
+ @instance = SolrInstance.new
+ end
+
+ context "when checking whether indexing is disabled" do
+
+ setup do
+ @instance.configuration = {:if => true}
+ end
+
+ should "return true if the specified proc returns true " do
+ @instance.configuration[:offline] = proc {|record| true}
+ assert @instance.indexing_disabled?
+ end
+
+ should "return false if the specified proc returns false" do
+ @instance.configuration[:offline] = proc {|record| false}
+ assert !@instance.indexing_disabled?
+ end
+
+ should "return true if no valid offline option was specified" do
+ @instance.configuration[:offline] = nil
+ @instance.configuration[:if] = proc {true}
+ assert !@instance.indexing_disabled?
+ end
+ end
+
+ context "when validating the boost" do
+ setup do
+ @instance.solr_configuration = {:default_boost => 10.0}
+ @instance.configuration = {:if => true}
+ end
+
+ should "accept and evaluate a block" do
+ @instance.configuration[:boost] = proc {|record| record.boost_rate}
+ assert_equal 10.0, @instance.send(:validate_boost, @instance.configuration[:boost])
+ end
+
+ should "accept and return a float" do
+ @instance.configuration[:boost] = 9.0
+ assert_equal 9.0, @instance.send(:validate_boost, @instance.configuration[:boost])
+ end
+
+ should "return the default float when the specified is negative" do
+ @instance.configuration[:boost] = -1.0
+ assert_equal 10.0, @instance.send(:validate_boost, @instance.configuration[:boost])
+ end
+
+ should "execute the according method when value is a symbol" do
+ @instance.configuration[:boost] = :irate
+ assert_equal 8.0, @instance.send(:validate_boost, @instance.configuration[:boost])
+ end
+
+ should "return the default boost when there is no valid boost" do
+ @instance.configuration[:boost] = "boost!"
+ assert_equal 10.0, @instance.send(:validate_boost, @instance.configuration[:boost])
+ end
+ end
+
+ context "when determining the solr document id" do
+ should "combine class name and id" do
+ assert_equal "SolrInstance:10", @instance.solr_id
+ end
+ end
+
+ context "when saving the instance to solr" do
+ context "with indexing disabled" do
+ setup do
+ @instance.configuration = {:fields => [:name], :if => nil}
+ end
+
+ should "just return and do nothing" do
+ @instance.expects(:solr_add).never
+ @instance.expects(:solr_destroy).never
+ assert @instance.solr_save
+ end
+ end
+
+ context "with indexing enabled" do
+ setup do
+ @instance.configuration = {:fields => [:name], :if => "true", :auto_commit => true}
+ @instance.stubs(:solr_commit)
+ @instance.stubs(:solr_add)
+ @instance.stubs(:to_solr_doc).returns("My test document")
+ end
+
+ should "add the solr document" do
+ @instance.expects(:solr_add).with("My test document").once
+ @instance.solr_save
+ end
+
+ should "commit to solr" do
+ @instance.expects(:solr_commit).once
+ @instance.solr_save
+ end
+
+ should "not commit if auto_commit is disabled" do
+ @instance.configuration.merge!(:auto_commit => false)
+ @instance.expects(:solr_commit).never
+ @instance.solr_save
+ end
+
+ should "destroy the document if :if clause is false" do
+ @instance.configuration.merge!(:if => "false")
+ @instance.expects(:solr_destroy).once
+ @instance.solr_save
+ end
+ end
+ end
+
+ context "when destroying an instance in solr" do
+ setup do
+ @instance.configuration = {:if => true, :auto_commit => true}
+ @instance.stubs(:solr_commit)
+ @instance.stubs(:solr_delete)
+ end
+
+ should "delete the instance" do
+ @instance.expects(:solr_delete).with("SolrInstance:10")
+ @instance.solr_destroy
+ end
+
+ should "commit to solr" do
+ @instance.expects(:solr_commit)
+ @instance.solr_destroy
+ end
+
+ should "not commit if auto_commit is disabled" do
+ @instance.configuration.merge!(:auto_commit => false)
+ @instance.expects(:solr_commit).never
+ @instance.solr_destroy
+ end
+
+ context "with indexing disabled" do
+ should "not contact solr" do
+ @instance.configuration.merge!(:offline => true, :if => nil)
+ @instance.expects(:solr_delete).never
+ @instance.solr_destroy
+ end
+ end
+ end
+
+ context "when converting an instance to a solr document" do
+ setup do
+ @instance.configuration = {:if => true, :auto_commit => true, :solr_fields => {:name => {:boost => 9.0}}, :boost => 10.0}
+ @instance.solr_configuration = {:type_field => "type", :primary_key_field => "pk_id", :default_boost => 25.0}
+ end
+
+ should "add a document boost" do
+ assert_equal 10, @instance.to_solr_doc.boost
+ end
+
+ should "set the solr id" do
+ assert_equal "SolrInstance:10", @instance.to_solr_doc[:id]
+ end
+
+ should "set the type field" do
+ assert_equal "SolrInstance", @instance.to_solr_doc[:type]
+ end
+
+ should "set the primary key fields" do
+ assert_equal("10", @instance.to_solr_doc[:pk_id])
+ end
+
+ should "add the includes if they were configured" do
+ @instance.configuration.merge! :include => [:author]
+ @instance.expects(:add_includes)
+ @instance.to_solr_doc
+ end
+
+ context "with a local" do
+ setup do
+ @local = Local.new '14.51', '-65.43'
+ @instance.stubs(:local).returns(@local)
+ @instance.configuration[:spatial] = true
+ @fields = @instance.to_solr_doc.fields
+ end
+
+ should "add the longitude" do
+ field = @fields.find { |field| field.name.eql? "lng" }
+ assert_equal @local.longitude, field.value
+ end
+
+ should "add the latitude" do
+ field = @fields.find { |field| field.name.eql? "lat" }
+ assert_equal @local.latitude, field.value
+ end
+ end
+
+ context "without a local" do
+ should "should ignore the spatial option" do
+ @instance.stubs(:local).returns(nil)
+ @instance.configuration[:spatial] = true
+ fields = @instance.to_solr_doc.fields
+ assert_equal nil, fields.find { |field| field.name.eql? 'lng' }
+ end
+ end
+
+ context "with indexed fields" do
+ should "add fields with type" do
+ assert_equal "Chunky bacon!", @instance.to_solr_doc[:name_s]
+ end
+
+ should "add the field boost" do
+ field = @instance.to_solr_doc.fields.find {|f| f.name.to_s == "name_s"}
+ assert_equal 9.0, field.boost
+ end
+
+ should "set the default boost for the field, if none is configured" do
+ @instance.configuration[:solr_fields][:name][:boost] = nil
+ field = @instance.to_solr_doc.fields.find {|f| f.name.to_s == "name_s"}
+ assert_equal 25.0, field.boost
+ end
+
+ should "not overwrite the type or id field" do
+ @instance.configuration[:solr_fields] = {:type => {}, :id => {}}
+ doc = @instance.to_solr_doc
+ assert_not_equal "humbug", doc[:type]
+ assert_not_equal "bogus", doc[:id]
+ end
+
+ should "set the default value if field value is nil" do
+ @instance.name = nil
+ @instance.expects(:set_value_if_nil).with('s')
+ @instance.to_solr_doc
+ end
+
+ should "not include nil values" do
+ @instance.name = ""
+ @instance.stubs(:set_value_if_nil).returns ""
+ assert_nil @instance.to_solr_doc[:name_s]
+ end
+
+ should "escape the contents" do
+ @instance.name = ""
+ assert_equal "<script>malicious()</script>", @instance.to_solr_doc[:name_s]
+ end
+
+ should "use an alternate field name if specified in options" do
+ @instance.stubs(:nickname_for_solr).returns('Nick')
+ @instance.configuration[:solr_fields].merge! :nickname => {:as => :alias}
+ doc = @instance.to_solr_doc
+ assert_not_nil @instance.to_solr_doc.fields.find {|f| f.name.to_s == "alias_s"}
+ assert_nil @instance.to_solr_doc.fields.find {|f| f.name.to_s == "nickname_s"}
+ end
+
+ context "when indexing tags" do
+ setup do
+ taggings = [Tagging.new('house'), Tagging.new('beach')].sort { |a, b| rand - 0.5 }
+ @instance.stubs(:taggings).returns(taggings)
+ @instance.configuration[:taggable] = true
+ @fields = @instance.to_solr_doc.fields
+ end
+
+ should "set the field name as tag of type text, so they can be found by a query without filters" do
+ assert_equal "tag_t", @fields.last.name
+ end
+
+ should "set the field value with the tag value" do
+ assert_equal @instance.taggings.last.tag.name, @fields.last.value
+ end
+
+ should "consider all of them" do
+ assert_equal @instance.taggings.size * 2, @fields.select { |f| f.name.include? "tag_" }.size
+ end
+
+ should "facet them" do
+ assert_equal @fields.select { |f| f.name.include? "tag_t" }.size,
+ @fields.select { |f| f.name.include? "tag_facet" }.size
+ end
+ end
+
+ context "when associations are included" do
+ setup do
+ class AssocLabel < String
+ @@singular = {'people' => 'person'}
+ def to_s
+ self
+ end
+ def singularize
+ @@singular[self]
+ end
+ end
+ @assoc = AssocLabel.new('people')
+ person = {:name => 'Hank Venture', :address => 'Venture Compound'}
+ @people = [OpenStruct.new(person.merge(:attributes => person))]
+ @instance.stubs(:people).returns(@people)
+ @reflection = OpenStruct.new(:macro => :has_many)
+ @instance.class.stubs(:reflect_on_association).returns(@reflection)
+ @instance.configuration[:solr_includes] = {@assoc => {}}
+ @instance.solr_configuration.merge! :default_boost => 35.0
+ end
+
+ should "set the default name for the include, if none is configured" do
+ @instance.configuration[:solr_includes] = {@assoc => {:type => :text}}
+ doc = @instance.to_solr_doc
+ assert_not_nil doc.fields.find {|f| f.name.to_s == "person_s"}
+ end
+
+ should "add the include alias" do
+ @instance.configuration[:solr_includes] = {@assoc => {:as => :human, :type => :text}}
+ doc = @instance.to_solr_doc
+ assert_not_nil doc.fields.find {|f| f.name.to_s == "human_s"}
+ assert_nil doc.fields.find {|f| f.name.to_s == "person_s"}
+ end
+
+ should "add the include type" do
+ @instance.configuration[:solr_includes] = {@assoc => {:type => :date}}
+ @instance.expects(:get_solr_field_type).with(){|v| true}.at_least_once.returns('s')
+ @instance.expects(:get_solr_field_type).with(:date).once.returns('d')
+ doc = @instance.to_solr_doc
+ end
+
+ should "set the default boost for the include, if none is configured" do
+ # @instance.configuration[:solr_includes] = {@assoc => {}}
+ field = @instance.to_solr_doc.fields.find {|f| f.name.to_s == "person_s"}
+ assert_equal 35.0, field.boost
+ end
+
+ should "add the include boost" do
+ @instance.configuration[:solr_includes] = {@assoc => {:boost => 10.0}}
+ field = @instance.to_solr_doc.fields.find {|f| f.name.to_s == "person_s"}
+ assert_equal 10.0, field.boost
+ end
+
+ should "default to a field value with all association attributes" do
+ # @instance.configuration[:solr_includes] = {@assoc => {}}
+ field = @instance.to_solr_doc.fields.find {|f| f.name.to_s == "person_s"}
+ @people.first.attributes.each do |attr, value|
+ assert_match /#{attr}=#{value}/, field.value
+ end
+ end
+
+ should "use a field value from an association method, if one is configured" do
+ @instance.configuration[:solr_includes] = {@assoc => {:using => :name}}
+ field = @instance.to_solr_doc.fields.find {|f| f.name.to_s == "person_s"}
+ assert_equal @people.first.name, field.value
+ end
+
+ should "use a field value from a proc, if one is configured" do
+ @instance.configuration[:solr_includes] = {@assoc => {:using => lambda{|r| r.name.reverse}}}
+ field = @instance.to_solr_doc.fields.find {|f| f.name.to_s == "person_s"}
+ assert_equal @people.first.name.reverse, field.value
+ end
+
+ should "join multiple values into a single field unless the :multivalued options is specified" do
+ @instance.configuration[:solr_includes] = {@assoc => {:multivalued => :true}}
+ second_person = {:name => 'Dean Venture', :address => 'Venture Compound'}
+ @people << OpenStruct.new(second_person.merge(:attributes => second_person))
+ fields = @instance.to_solr_doc.fields.select {|f| f.name.to_s == "person_s"}
+ assert_equal @people.size, fields.size
+ end
+
+ should "include multiple values separately if the :multivalued options is specified" do
+ # @instance.configuration[:solr_includes] = {@assoc => {}}
+ second_person = {:name => 'Dean Venture', :address => 'Venture Compound'}
+ @people << OpenStruct.new(second_person.merge(:attributes => second_person))
+ fields = @instance.to_solr_doc.fields.select {|f| f.name.to_s == "person_s"}
+ assert_not_equal @people.size, fields.size
+ assert_equal 1, fields.size
+ end
+ end
+ end
+ end
+ end
+end
diff --git a/vendor/plugins/acts_as_solr_reloaded/test/unit/lazy_document_shoulda.rb b/vendor/plugins/acts_as_solr_reloaded/test/unit/lazy_document_shoulda.rb
new file mode 100644
index 0000000..e2ceb68
--- /dev/null
+++ b/vendor/plugins/acts_as_solr_reloaded/test/unit/lazy_document_shoulda.rb
@@ -0,0 +1,34 @@
+require File.expand_path("#{File.dirname(__FILE__)}/test_helper")
+
+class UserModel; end
+
+class LazyDocumentTest < Test::Unit::TestCase
+ context "With a lazy document" do
+ setup do
+ @record = stub(:record)
+ @record.stubs(:is_valid?).returns true
+ UserModel.stubs(:find).returns @record
+ @document = ActsAsSolr::LazyDocument.new(1, UserModel)
+ end
+
+ context "with an uninitialized document" do
+ should "fetch the record from the database" do
+ UserModel.expects(:find).with(1).returns(@record)
+ @document.is_valid?
+ end
+ end
+
+ context "with an initialized document" do
+ should "not fetch the record again" do
+ @document.is_valid?
+ @document.expects(:find).never
+ @document.is_valid?
+ end
+
+ should "reroute the calls to the record" do
+ @record.expects(:is_valid?).once
+ @document.is_valid?
+ end
+ end
+ end
+end
diff --git a/vendor/plugins/acts_as_solr_reloaded/test/unit/parser_instance.rb b/vendor/plugins/acts_as_solr_reloaded/test/unit/parser_instance.rb
new file mode 100644
index 0000000..0f48943
--- /dev/null
+++ b/vendor/plugins/acts_as_solr_reloaded/test/unit/parser_instance.rb
@@ -0,0 +1,19 @@
+class ActsAsSolr::ParserInstance
+ include ActsAsSolr::ParserMethods
+ include ActsAsSolr::CommonMethods
+ attr_accessor :configuration, :solr_configuration
+
+ def table_name
+ "documents"
+ end
+
+ def primary_key
+ "id"
+ end
+
+ def find(*args)
+ []
+ end
+
+ public :parse_results, :reorder, :parse_query, :add_scores, :replace_types
+end
\ No newline at end of file
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
new file mode 100644
index 0000000..e01e3ed
--- /dev/null
+++ b/vendor/plugins/acts_as_solr_reloaded/test/unit/parser_methods_shoulda.rb
@@ -0,0 +1,352 @@
+require File.expand_path("#{File.dirname(__FILE__)}/test_helper")
+
+class ParserMethodsTest < Test::Unit::TestCase
+
+ context "With a parser instance" do
+ setup do
+ @parser = ActsAsSolr::ParserInstance.new
+ end
+
+ context "When parsing results" do
+ setup do
+ @results = stub(:results)
+ @results.stubs(:total_hits).returns(2)
+ @results.stubs(:hits).returns([])
+ @results.stubs(:max_score).returns 2.1
+ @results.stubs(:highlighting).returns []
+ @results.stubs(:data).returns({"responseHeader" => {"QTime" => "10.2"}})
+ @results.stubs(:header).returns({})
+ end
+
+ should "return a SearchResults object" do
+ assert_equal ActsAsSolr::SearchResults, @parser.parse_results(@results).class
+ end
+
+ should "set the max score" do
+ assert_equal 2.1, @parser.parse_results(@results).max_score
+ end
+
+ should "include the facets" do
+ @results.stubs(:data).returns({"responseHeader" => {"QTime" => "10.2"}, "facet_counts" => 2})
+ assert_equal 2, @parser.parse_results(@results, :facets => true).facets
+ end
+
+ context "when the format requests objects" do
+ setup do
+ @parser.configuration = {:format => :objects}
+ @parser.solr_configuration = {:primary_key_field => :pk_id}
+ @results.stubs(:hits).returns [{"pk_id" => 1}, {"pk_id" => 2}]
+ @parser.stubs(:reorder)
+ end
+
+ should "query with the record ids" do
+ @parser.expects(:find).with([1, 2], {}).returns [1, 2]
+ @parser.parse_results(@results)
+ end
+
+ should "reorder the records" do
+ @parser.expects(:reorder).with([], [1, 2])
+ @parser.parse_results(@results)
+ end
+
+ should "add :include if :include was specified" do
+ @parser.expects(:find).with([1, 2], :include => [:author]).returns [1, 2]
+ @parser.parse_results(@results, :include => [:author])
+ end
+ end
+
+ context "when the format doesn't request objects" do
+ setup do
+ @parser.solr_configuration = {:primary_key_field => "pk_id"}
+ end
+
+ should "not query the database" do
+ @parser.expects(:find).never
+ @parser.parse_results(@results, :format => nil)
+ end
+
+ should "return just the ids" do
+ @results.stubs(:hits).returns([{"pk_id" => 1}, {"pk_id" => 2}])
+ assert_equal [1, 2], @parser.parse_results(@results, :format => nil).docs
+ end
+
+ should "ignore the :lazy option" do
+ @results.stubs(:hits).returns([{"pk_id" => 1}, {"pk_id" => 2}])
+ assert_equal [1, 2], @parser.parse_results(@results, :format => :ids, :lazy => true).docs
+ end
+ end
+
+ context "with an empty result set" do
+ setup do
+ @results.stubs(:total_hits).returns(0)
+ @results.stubs(:hits).returns([])
+ end
+
+ should "return an empty search results set" do
+ assert_equal 0, @parser.parse_results(@results).total
+ end
+
+ should "not have any search results" do
+ assert_equal [], @parser.parse_results(@results).docs
+ end
+ end
+
+ context "with a nil result set" do
+ should "return an empty search results set" do
+ assert_equal 0, @parser.parse_results(nil).total
+ end
+ end
+
+ context "with the scores option" do
+ should "add the scores" do
+ @parser.expects(:add_scores).with([], @results)
+ @parser.parse_results(@results, :scores => true)
+ end
+ end
+
+ context "with lazy format" do
+ setup do
+ @parser.solr_configuration = {:primary_key_field => :pk_id}
+ @results.stubs(:hits).returns([{"pk_id" => 1}, {"pk_id" => 2}])
+ end
+
+ should "create LazyDocuments for the resulting docs" do
+ result = @parser.parse_results(@results, :lazy => true)
+ assert_equal ActsAsSolr::LazyDocument, result.results.first.class
+ end
+
+ should "set the document id as the record id" do
+ result = @parser.parse_results(@results, :lazy => true)
+ assert_equal 1, result.results.first.id
+ end
+
+ should "set the document class" do
+ result = @parser.parse_results(@results, :lazy => true)
+ assert_equal ActsAsSolr::ParserInstance, result.results.first.clazz.class
+ end
+ end
+
+ end
+
+ context "when reordering results" do
+ should "raise an error if arguments don't have the same number of elements" do
+ assert_raise(RuntimeError) {@parser.reorder([], [1])}
+ end
+
+ should "reorder the results to match the order of the documents returned by solr" do
+ thing1 = stub(:thing1)
+ thing1.stubs(:id).returns 5
+ thing2 = stub(:thing2)
+ thing2.stubs(:id).returns 1
+ thing3 = stub(:things3)
+ thing3.stubs(:id).returns 3
+ things = [thing1, thing2, thing3]
+ reordered = @parser.reorder(things, ['1', '3', '5'])
+ assert_equal [1, 3, 5], reordered.collect{|thing| thing.id}
+ end
+ end
+
+ context "When parsing a query" do
+ setup do
+ ActsAsSolr::Post.stubs(:execute)
+ @parser.stubs(:solr_type_condition).returns "(type:ParserMethodsTest)"
+ @parser.solr_configuration = {:primary_key_field => "id"}
+ @parser.configuration = {:solr_fields => nil}
+ end
+
+ should "set the limit and offset" do
+ ActsAsSolr::Post.expects(:execute).with {|request, core|
+ 10 == request.to_hash[:rows]
+ 20 == request.to_hash[:start]
+ }
+ @parser.parse_query "foo", :limit => 10, :offset => 20
+ end
+
+ should "set the relevancy of the specified fields and non-filtered terms" do
+ ActsAsSolr::Post.expects(:execute).with {|request, core|
+ q = request.to_hash[:q]
+ q.starts_with?("(aeroplane brasil continent_t:south OR tag_t:(aeroplane brasil)^5 OR description_t:(aeroplane brasil)^3)") or q.starts_with?("(aeroplane brasil continent_t:south OR description_t:(aeroplane brasil)^3 OR tag_t:(aeroplane brasil)^5)")
+ }
+ @parser.parse_query "aeroplane brasil continent:south", :relevance => {:tag => 5, :description => 3}
+ end
+
+ should "set the relevance unless no query specified" do
+ expected = "(continent_t:south)"
+ ActsAsSolr::Post.expects(:execute).with {|request, core|
+ request.to_hash[:q].starts_with? expected
+ }
+ @parser.parse_query "continent:south", :relevance => {:tag => 5, :description => 3}
+ end
+
+ should "set the relevance with simple queries" do
+ ActsAsSolr::Post.expects(:execute).with {|request, core|
+ q = request.to_hash[:q]
+ q.starts_with?("(car OR tag_t:(car)^5 OR description_t:(car)^3)") or q.starts_with?("(car OR description_t:(car)^3 OR tag_t:(car)^5)")
+ }
+ @parser.parse_query "car", :relevance => {:tag => 5, :description => 3}
+ end
+
+ should "not execute anything if the query is nil" do
+ ActsAsSolr::Post.expects(:execute).never
+ assert_nil @parser.parse_query(nil)
+ end
+
+ should "not execute anything if the query is ''" do
+ ActsAsSolr::Post.expects(:execute).never
+ assert_nil @parser.parse_query('')
+ end
+
+ should "raise an error if invalid options where specified" do
+ assert_raise(RuntimeError) {@parser.parse_query "foo", :invalid => true}
+ end
+
+ should "add the type" do
+ ActsAsSolr::Post.expects(:execute).with {|request, core|
+ request.to_hash[:q].include?("(type:ParserMethodsTest)")
+ }
+ @parser.parse_query "foo"
+ end
+
+ should "append the field types for the specified fields" do
+ ActsAsSolr::Post.expects(:execute).with {|request, core|
+ request.to_hash[:q].include?("(username_t:Chunky)")
+ }
+ @parser.parse_query "username:Chunky"
+ end
+
+ should "replace the field types" do
+ @parser.expects(:replace_types).returns(["active_i:1"])
+ ActsAsSolr::Post.expects(:execute).with {|request, core|
+ request.to_hash[:q].include?("active_i:1")
+ }
+ @parser.parse_query "active:1"
+ end
+
+ should "add score and primary key to field list" do
+ ActsAsSolr::Post.expects(:execute).with {|request, core|
+ request.to_hash[:fl] == ('id,score')
+ }
+ @parser.parse_query "foo"
+ end
+
+ should "add highlight options" do
+ ActsAsSolr::Post.expects(:execute).with {|request, core|
+ request.to_hash[:hl] == "true"
+ request.to_hash["hl.fl"] == "title_t"
+ }
+ @parser.parse_query "car", :highlight => {:fields => "title"}
+ end
+
+ should "set the operator" do
+ ActsAsSolr::Post.expects(:execute).with {|request, core|
+ "OR" == request.to_hash["q.op"]
+ }
+ @parser.parse_query "foo", :operator => :or
+ end
+
+ should "activate spellcheck" do
+ ActsAsSolr::Post.expects(:execute).with {|request, core|
+ request.to_hash[:spellcheck] == true
+ }
+ @parser.parse_query "foo"
+ end
+
+ should "activate spellcheck collation" do
+ ActsAsSolr::Post.expects(:execute).with {|request, core|
+ request.to_hash['spellcheck.collate'] == true
+ }
+ @parser.parse_query "foo"
+ end
+
+ context "with the around option" do
+ should "set the qt as geo" do
+ 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}
+ 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}
+ 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}
+ 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}
+ end
+ end
+
+ context "with the order option" do
+ should "add the order criteria to the query" do
+ ActsAsSolr::Post.expects(:execute).with {|request, core|
+ request.to_hash[:sort].include?("active_t desc")
+ }
+ @parser.parse_query "active:1", :order => "active desc"
+ end
+ end
+
+ context "with facets" do
+ end
+end
+
+context "When setting the field types" do
+ setup do
+ @parser.configuration = {:solr_fields => {:name => {:type => :string},
+ :age => {:type => :integer}}}
+ end
+
+ should "replace the _t suffix with the real type" do
+ assert_equal ["name_s:Chunky AND age_i:21"], @parser.replace_types(["name_t:Chunky AND age_t:21"])
+ end
+
+ context "with a suffix" do
+ should "not include the colon when false" do
+ assert_equal ["name_s"], @parser.replace_types(["name_t"], false)
+ end
+
+ should "include the colon by default" do
+ assert_equal ["name_s:Chunky"], @parser.replace_types(["name_t:Chunky"])
+ end
+ end
+end
+
+context "When adding scores" do
+ setup do
+ @solr_data = stub(:results)
+ @solr_data.stubs(:total_hits).returns(1)
+ @solr_data.stubs(:hits).returns([{"id" => 2, "score" => 2.546}])
+ @solr_data.stubs(:max_score).returns 2.1
+
+ @results = [Array.new]
+
+ @parser.stubs(:record_id).returns(2)
+
+ @parser.solr_configuration = {:primary_key_field => "id"}
+ end
+
+ should "add the score to the result document" do
+ assert_equal 2.546, @parser.add_scores(@results, @solr_data).first.last.solr_score
+ end
+end
+ end
+end
diff --git a/vendor/plugins/acts_as_solr_reloaded/test/unit/solr_instance.rb b/vendor/plugins/acts_as_solr_reloaded/test/unit/solr_instance.rb
new file mode 100644
index 0000000..d551986
--- /dev/null
+++ b/vendor/plugins/acts_as_solr_reloaded/test/unit/solr_instance.rb
@@ -0,0 +1,70 @@
+class SolrInstance
+ include ActsAsSolr::InstanceMethods
+ attr_accessor :configuration, :solr_configuration, :name
+
+ class << self
+ include ActsAsSolr::ActsMethods
+ include ActsAsSolr::ClassMethods
+ end
+
+ def initialize(name = "Chunky bacon!")
+ @name = name
+ end
+
+ def self.primary_key
+ "id"
+ end
+
+ def record_id(obj)
+ 10
+ end
+
+ def boost_rate
+ 10.0
+ end
+
+ def irate
+ 8.0
+ end
+
+ def name_for_solr
+ name
+ end
+
+ def id_for_solr
+ "bogus"
+ end
+
+ def type_for_solr
+ "humbug"
+ end
+
+ def get_solr_field_type(args)
+ "s"
+ end
+end
+
+class Tagging
+ attr_reader :tag
+
+ def initialize(name)
+ @tag = Tag.new name
+ end
+end
+
+class Tag
+ attr_reader :name
+
+ def initialize(name)
+ @name = name
+ end
+end
+
+class Local
+ attr_reader :longitude, :latitude
+
+ def initialize(long, lati)
+ @longitude = long
+ @latitude = lati
+ end
+end
diff --git a/vendor/plugins/acts_as_solr_reloaded/test/unit/test_helper.rb b/vendor/plugins/acts_as_solr_reloaded/test/unit/test_helper.rb
new file mode 100644
index 0000000..ac6cb3a
--- /dev/null
+++ b/vendor/plugins/acts_as_solr_reloaded/test/unit/test_helper.rb
@@ -0,0 +1,30 @@
+dir = File.dirname(__FILE__)
+$:.unshift(File.join(File.expand_path(dir), "..", "..", "lib"))
+
+require 'rubygems'
+require 'test/unit'
+require 'acts_as_solr'
+require 'mocha'
+require 'active_support'
+require 'logger'
+require File.expand_path("#{dir}/solr_instance")
+require File.expand_path("#{dir}/parser_instance")
+require 'erb'
+require 'ostruct'
+require 'mongo_mapper'
+
+if RUBY_VERSION =~ /^1\.9/
+ puts "\nRunning the unit test suite doesn't as of yet work with Ruby 1.9, because Mocha hasn't yet been updated to use minitest."
+ puts
+ exit 1
+end
+
+require 'mocha'
+gem 'thoughtbot-shoulda'
+require 'shoulda'
+
+class Rails
+ def self.logger
+ Logger.new(StringIO.new)
+ end
+end
--
libgit2 0.21.2