Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

Comparing changes

Choose two branches to see what's changed or to start a new pull request. If you need to, you can also compare across forks.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also compare across forks.
base fork: sunspot/sunspot
...
head fork: fiverr/sunspot
Checking mergeability… Don't worry, you can still create the pull request.
  • 4 commits
  • 5 files changed
  • 0 commit comments
  • 1 contributor
View
10 sunspot/lib/sunspot/query/common_query.rb
@@ -5,11 +5,11 @@ def initialize(types)
@scope = Scope.new
@sort = SortComposite.new
@components = [@scope, @sort]
- if types.length == 1
- @scope.add_positive_restriction(TypeField.instance, Restriction::EqualTo, types.first)
- else
- @scope.add_positive_restriction(TypeField.instance, Restriction::AnyOf, types)
- end
+ # if types.length == 1
+ # @scope.add_positive_restriction(TypeField.instance, Restriction::EqualTo, types.first)
+ # else
+ # @scope.add_positive_restriction(TypeField.instance, Restriction::AnyOf, types)
+ # end
end
def solr_parameter_adjustment=(block)
View
2  sunspot/lib/sunspot/query/dismax.rb
@@ -24,7 +24,7 @@ def to_params
params = { :q => @keywords }
params[:fl] = '* score'
params[:qf] = @fulltext_fields.values.map { |field| field.to_boosted_field }.join(' ')
- params[:defType] = 'dismax'
+ params[:defType] = 'edismax'
if @phrase_fields
params[:pf] = @phrase_fields.map { |field| field.to_boosted_field }.join(' ')
end
View
12 sunspot/lib/sunspot/query/restriction.rb
@@ -303,6 +303,18 @@ def to_solr_conditional
"#{solr_value(@value)}*"
end
end
+
+ #
+ # Results must have a field with a value that begins with the argument.
+ # Most useful for strings, but in theory will work with anything.
+ #
+ class Contains < Base
+ private
+
+ def to_solr_conditional
+ "*#{solr_value(@value)}*"
+ end
+ end
end
end
end
View
2  sunspot/lib/sunspot/search/hit.rb
@@ -27,7 +27,7 @@ class Hit
attr_writer :result #:nodoc:
def initialize(raw_hit, highlights, search) #:nodoc:
- @class_name, @primary_key = *raw_hit['id'].match(/([^ ]+) (.+)/)[1..2]
+ @class_name, @primary_key = raw_hit["class_name"], raw_hit["id"] #*raw_hit['id'].match(/([^ ]+) (.+)/)[1..2]
@score = raw_hit['score']
@search = search
@stored_values = raw_hit
View
24 sunspot/lib/sunspot/session.rb
@@ -24,6 +24,12 @@ def connection_class #:nodoc:
#
attr_reader :config
+ #
+ # rsolr::connection hash objects per core
+ #
+ attr_accessor :connections
+ @connections = {}
+
#
# Sessions are initialized with a Sunspot configuration and a Solr
# connection. Usually you will want to stick with the default arguments
@@ -32,8 +38,8 @@ def connection_class #:nodoc:
def initialize(config = Configuration.build, connection = nil)
@config = config
yield(@config) if block_given?
- @connection = connection
- @deletes = @adds = 0
+ @connections = {}
+ @deletes = @adds = 0
end
#
@@ -41,6 +47,7 @@ def initialize(config = Configuration.build, connection = nil)
#
def new_search(*types, &block)
types.flatten!
+ @types = types
search = Search::StandardSearch.new(
connection,
setup_for_types(types),
@@ -54,7 +61,7 @@ def new_search(*types, &block)
#
# See Sunspot.search
#
- def search(*types, &block)
+ def search(*types, &block)
search = new_search(*types, &block)
search.execute
end
@@ -237,9 +244,14 @@ def batch
#
# RSolr::Connection::Base:: The connection for this session
#
- def connection
- @connection ||=
- self.class.connection_class.connect(:url => config.solr.url,
+ def connection
+ if @types.empty? || @types.length > 1
+ raise(ArgumentError, "You must exactly one type to search")
+ end
+ core = @types.first.name
+ core_url = config.solr.url + '/' + core.downcase.pluralize
+
+ self.connections[core.to_sym] ||= self.class.connection_class.connect(:url => core_url,
:read_timeout => config.solr.read_timeout,
:open_timeout => config.solr.open_timeout)
end

No commit comments for this range

Something went wrong with that request. Please try again.