Module: HighlightQuery

Included in:
SearchQuery
Defined in:
app/queries/highlight_query.rb

Instance Method Summary collapse

Instance Method Details

#highlightLength(fieldName) ⇒ Object

Truncate highlighted field only when needed



18
19
20
21
22
23
24
25
# File 'app/queries/highlight_query.rb', line 18

def highlightLength(fieldName)
  # Check fields queried to see if it is truncated
  if use_all_or_some("truncated_fields", @all_truncated_fields).include?(fieldName)
    return {}
  else
    return {number_of_fragments: 0}
  end
end

#specify_fields_to_highlight(queryhash, highlighthash) ⇒ Object

Figure out which fields to highlight based on which ones were searched for



3
4
5
6
7
8
9
10
11
12
13
14
15
# File 'app/queries/highlight_query.rb', line 3

def specify_fields_to_highlight(queryhash, highlighthash)
  if !queryhash.empty? && queryhash[:simple_query_string]
      queryhash[:simple_query_string][:fields].each do |k|
      if k == "_all"
        @all_field_info.each {|f| highlighthash[f["Field Name"]] = highlightLength(f["Field Name"])}
      else
        highlighthash[k] = highlightLength(k.to_s)
      end
    end
  end
  
  return highlighthash
end