Class: Sunspot::Query::Highlighting
- Inherits:
-
Object
- Object
- Sunspot::Query::Highlighting
- Defined in:
- lib/sunspot/query/highlighting.rb
Overview
A query component that builds parameters for requesting highlights
Instance Method Summary collapse
-
#initialize(fields = [], options = {}) ⇒ Highlighting
constructor
:nodoc:.
- #to_params ⇒ Object
Constructor Details
#initialize(fields = [], options = {}) ⇒ Highlighting
:nodoc:
7 8 9 10 |
# File 'lib/sunspot/query/highlighting.rb', line 7 def initialize(fields=[], ={}) @fields = fields @options = end |
Instance Method Details
#to_params ⇒ Object
12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 |
# File 'lib/sunspot/query/highlighting.rb', line 12 def to_params params = { :hl => 'on', :"hl.simple.pre" => '@@@hl@@@', :"hl.simple.post" => '@@@endhl@@@' } unless @fields.empty? params[:"hl.fl"] = @fields.map { |field| field.indexed_name } end if max_snippets = @options[:max_snippets] params[:"hl.snippets"] = max_snippets end if fragment_size = @options[:fragment_size] params[:"hl.fragsize"] = fragment_size end if @options[:merge_continuous_fragments] params[:"hl.mergeContinuous"] = 'true' end if @options[:phrase_highlighter] params[:"hl.usePhraseHighlighter"] = 'true' if @options[:require_field_match] params[:"hl.requireFieldMatch"] = 'true' end end params end |