Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Added support for multiple cores and additional standard activerecord…

… query options
  • Loading branch information...
commit 2c7d1137a856226e9e5b43d058a1e2ae47535209 1 parent 9c7c8b0
@oxtralite oxtralite authored
Showing with 6 additions and 3 deletions.
  1. +2 −1  lib/acts_as_solr.rb
  2. +4 −2 lib/acts_as_solr/parser_methods.rb
View
3  lib/acts_as_solr.rb
@@ -39,7 +39,7 @@
module ActsAsSolr
class Post
- def self.execute(request)
+ def self.execute(request, core = nil)
begin
if File.exists?(RAILS_ROOT+'/config/solr.yml')
config = YAML::load_file(RAILS_ROOT+'/config/solr.yml')
@@ -49,6 +49,7 @@ def self.execute(request)
else
url = 'http://localhost:8982/solr'
end
+ url += "/" + core if !core.nil?
connection = Solr::Connection.new(url)
return connection.send(request)
rescue
View
6 lib/acts_as_solr/parser_methods.rb
@@ -4,7 +4,7 @@ module ParserMethods
# 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]
+ valid_options = [:offset, :limit, :facets, :models, :results_format, :order, :scores, :operator, :include, :lazy, :joins, :select, :core]
query_options = {}
return nil if (query.nil? || query.strip == '')
@@ -79,7 +79,7 @@ def parse_query(query=nil, options={}, models=nil)
query_options[:query] << ';' << replace_types([order], false)[0]
end
- ActsAsSolr::Post.execute(Solr::Request::Standard.new(query_options))
+ 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
@@ -125,6 +125,8 @@ def find_objects(ids, options, configuration)
conditions = [ "#{self.table_name}.#{primary_key} in (?)", ids ]
find_options = {:conditions => conditions}
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(:all, find_options), ids)
else
ids
Please sign in to comment.
Something went wrong with that request. Please try again.