Solr query abstraction
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 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
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 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 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
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
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