class Sunspot::Query::AbstractFulltext

Solr query abstraction

Attributes

fulltext_fields[R]

Public Instance Methods

add_additive_boost_function(function_query) click to toggle source

Add a boost function

# File lib/sunspot/query/abstract_fulltext.rb, line 21
def add_additive_boost_function(function_query)
  @additive_boost_functions << function_query
end
add_fulltext_field(field, boost = nil) click to toggle source

Add a fulltext field to be searched, with optional boost.

# File lib/sunspot/query/abstract_fulltext.rb, line 35
def add_fulltext_field(field, boost = nil)
  @fulltext_fields[field.indexed_name] = TextFieldBoost.new(field, boost)
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/abstract_fulltext.rb, line 52
def add_highlight(fields=[], options={})
  @highlights << Highlighting.new(fields, options)
end
add_multiplicative_boost_function(function_query) click to toggle source

Add a multiplicative boost function

# File lib/sunspot/query/abstract_fulltext.rb, line 28
def add_multiplicative_boost_function(function_query)
  @multiplicative_boost_functions << function_query
end
add_phrase_field(field, boost = nil) click to toggle source

Add a phrase field for extra boost.

# File lib/sunspot/query/abstract_fulltext.rb, line 42
def add_phrase_field(field, boost = nil)
  @phrase_fields ||= []
  @phrase_fields << TextFieldBoost.new(field, boost)
end
create_boost_query(factor) click to toggle source

Assign a new boost query and return it.

# File lib/sunspot/query/abstract_fulltext.rb, line 13
def create_boost_query(factor)
  @boost_queries << boost_query = BoostQuery.new(factor)
  boost_query
end
has_fulltext_field?(field) click to toggle source

Determine if a given field is being searched. Used by DSL to avoid overwriting boost parameters when injecting defaults.

# File lib/sunspot/query/abstract_fulltext.rb, line 60
def has_fulltext_field?(field)
  @fulltext_fields.has_key?(field.indexed_name)
end