Class: Workarea::Search::RelatedHelp

Inherits:
Object
  • Object
show all
Includes:
Pagination, Query
Defined in:
app/queries/workarea/search/related_help.rb

Overview

TODO remove related help in v4

Instance Method Summary collapse

Methods included from Pagination

#each_by, #from, #page, #per_page

Methods included from Query

#additional_options, #aggregations, #body, #id, #initialize, #load_model_from, #loaded_results, #post_filter, #query_string, #response, #scroll, #stats, #total

Instance Method Details

#queryObject



10
11
12
13
14
15
16
17
18
19
20
# File 'app/queries/workarea/search/related_help.rb', line 10

def query
  {
    more_like_this: {
      min_term_freq: 1,
      min_doc_freq: 1,
      fields: %w(name facets.category body),
      ids: Array(params[:ids]),
      like_text: params[:like_text]
    }
  }
end

#resultsObject



26
27
28
29
30
31
32
33
34
35
# File 'app/queries/workarea/search/related_help.rb', line 26

def results
  @_results ||=
    if results_with_url_matching.blank?
       use_more_like_this? ? super : []
    elsif use_more_like_this?
      combine_url_matching_with(super)
    else
      []
    end
end

#results_with_url_matchingObject



37
38
39
40
# File 'app/queries/workarea/search/related_help.rb', line 37

def results_with_url_matching
  return [] unless params[:for_url].present?
  Workarea::Help::Article.find_matching_url(params[:for_url])
end

#sizeObject



22
23
24
# File 'app/queries/workarea/search/related_help.rb', line 22

def size
  Workarea.config.max_admin_related_help
end

#use_more_like_this?Boolean

Returns:

  • (Boolean)


42
43
44
# File 'app/queries/workarea/search/related_help.rb', line 42

def use_more_like_this?
  params[:like_text].present? || params[:ids].present?
end