class Sunspot::Query::Join
Solr full-text queries use Solr's JoinRequestHandler.
Attributes
minimum_match[W]
phrase_slop[W]
query_phrase_slop[W]
tie[W]
Public Class Methods
new(keywords, target, from, to)
click to toggle source
# File lib/sunspot/query/join.rb, line 10 def initialize(keywords, target, from, to) @keywords = keywords @target = target @from = from @to = to @fulltext_fields = {} @minimum_match = nil end
Public Instance Methods
add_boost_function(function_query)
click to toggle source
Add a boost function
# File lib/sunspot/query/join.rb, line 61 def add_boost_function(function_query) end
add_fulltext_field(field, boost = nil)
click to toggle source
Add a fulltext field to be searched, with optional boost.
Calls superclass method
Sunspot::Query::AbstractFulltext#add_fulltext_field
# File lib/sunspot/query/join.rb, line 67 def add_fulltext_field(field, boost = nil) super if field.is_a?(Sunspot::JoinField) && field.target == @target && field.from == @from && field.to == @to end
add_highlight(fields=[], options={})
click to toggle source
Set highlighting options for the query. If fields is empty, the Highlighting
object won't pass field names at all, which means the dismax's :qf parameter will be used by Solr.
# File lib/sunspot/query/join.rb, line 83 def add_highlight(fields=[], options={}) end
add_phrase_field(field, boost = nil)
click to toggle source
Add a phrase field for extra boost.
# File lib/sunspot/query/join.rb, line 75 def add_phrase_field(field, boost = nil) end
create_boost_query(factor)
click to toggle source
Assign a new boost query and return it.
# File lib/sunspot/query/join.rb, line 55 def create_boost_query(factor) end
to_params()
click to toggle source
The query as Solr parameters
# File lib/sunspot/query/join.rb, line 24 def to_params params = { :q => @keywords } params[:fl] = '* score' params[:qf] = @fulltext_fields.values.map { |field| field.to_boosted_field }.join(' ') params[:defType] = 'join' params[:mm] = @minimum_match if @minimum_match params end
to_subquery()
click to toggle source
Serialize the query as a Solr nested subquery.
# File lib/sunspot/query/join.rb, line 37 def to_subquery params = self.to_params params.delete :defType params.delete :fl keywords = escape_quotes(params.delete(:q)) options = params.map { |key, value| escape_param(key, value) }.join(' ') q_name = "q#{@target.name}#{self.object_id}" { :q => "_query_:\"{!join from=#{@from} to=#{@to} v=$#{q_name}}\"", q_name => "_query_:\"{!field f=type}#{@target.name}\"+_query_:\"{!edismax #{options}}#{keywords}\"" } end