Class: Sunspot::Query::Join
- Inherits:
-
AbstractFulltext
- Object
- AbstractFulltext
- Sunspot::Query::Join
- Defined in:
- lib/sunspot/query/join.rb
Overview
Solr full-text queries use Solr’s JoinRequestHandler.
Instance Attribute Summary collapse
-
#minimum_match ⇒ Object
writeonly
Sets the attribute minimum_match.
-
#phrase_slop ⇒ Object
writeonly
Sets the attribute phrase_slop.
-
#query_phrase_slop ⇒ Object
writeonly
Sets the attribute query_phrase_slop.
-
#tie ⇒ Object
writeonly
Sets the attribute tie.
Attributes inherited from AbstractFulltext
Instance Method Summary collapse
-
#add_boost_function(function_query) ⇒ Object
Add a boost function.
-
#add_boost_query(factor) ⇒ Object
Assign a new boost query and return it.
-
#add_fulltext_field(field, boost = nil) ⇒ Object
Add a fulltext field to be searched, with optional boost.
-
#add_highlight(fields = [], options = {}) ⇒ Object
Set highlighting options for the query.
-
#add_phrase_field(field, boost = nil) ⇒ Object
Add a phrase field for extra boost.
-
#initialize(keywords, target, from, to) ⇒ Join
constructor
A new instance of Join.
-
#to_params ⇒ Object
The query as Solr parameters.
-
#to_subquery ⇒ Object
Serialize the query as a Solr nested subquery.
Methods inherited from AbstractFulltext
#add_additive_boost_function, #add_multiplicative_boost_function, #has_fulltext_field?
Constructor Details
#initialize(keywords, target, from, to) ⇒ Join
10 11 12 13 14 15 16 17 18 19 |
# 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 |
Instance Attribute Details
#minimum_match=(value) ⇒ Object (writeonly)
Sets the attribute minimum_match
8 9 10 |
# File 'lib/sunspot/query/join.rb', line 8 def minimum_match=(value) @minimum_match = value end |
#phrase_slop=(value) ⇒ Object (writeonly)
Sets the attribute phrase_slop
8 9 10 |
# File 'lib/sunspot/query/join.rb', line 8 def phrase_slop=(value) @phrase_slop = value end |
#query_phrase_slop=(value) ⇒ Object (writeonly)
Sets the attribute query_phrase_slop
8 9 10 |
# File 'lib/sunspot/query/join.rb', line 8 def query_phrase_slop=(value) @query_phrase_slop = value end |
#tie=(value) ⇒ Object (writeonly)
Sets the attribute tie
8 9 10 |
# File 'lib/sunspot/query/join.rb', line 8 def tie=(value) @tie = value end |
Instance Method Details
#add_boost_function(function_query) ⇒ Object
Add a boost function
61 62 |
# File 'lib/sunspot/query/join.rb', line 61 def add_boost_function(function_query) end |
#add_boost_query(factor) ⇒ Object
Assign a new boost query and return it.
55 56 |
# File 'lib/sunspot/query/join.rb', line 55 def add_boost_query(factor) end |
#add_fulltext_field(field, boost = nil) ⇒ Object
Add a fulltext field to be searched, with optional boost.
67 68 69 70 |
# 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 = {}) ⇒ Object
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.
83 84 |
# File 'lib/sunspot/query/join.rb', line 83 def add_highlight(fields=[], ={}) end |
#add_phrase_field(field, boost = nil) ⇒ Object
Add a phrase field for extra boost.
75 76 |
# File 'lib/sunspot/query/join.rb', line 75 def add_phrase_field(field, boost = nil) end |
#to_params ⇒ Object
The query as Solr parameters
24 25 26 27 28 29 30 31 32 |
# 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 ⇒ Object
Serialize the query as a Solr nested subquery.
37 38 39 40 41 42 43 44 45 46 47 48 49 50 |
# 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)) = 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 #{}}#{keywords}\"" } end |