Sha256: 6e6fbf1fd0614d7d6895581b4985ad64b1d37c2a0a7e7d8ebe2bab4eca1b62e1

Contents?: true

Size: 968 Bytes

Versions: 1

Compression:

Stored size: 968 Bytes

Contents

module Sunspot
  module Query
    #
    # A query component that builds parameters for requesting highlights
    #
    class Highlighting #:nodoc:
      def initialize(options)
        @options = options
      end

      def to_params
        params = {
          :hl => 'on',
          :"hl.simple.pre" => '@@@hl@@@',
          :"hl.simple.post" => '@@@endhl@@@'
        }
        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
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
benjaminkrause-sunspot-0.9.7 lib/sunspot/query/highlighting.rb