Module: Europeana::Blacklight::SearchBuilder::MoreLikeThis

Extended by:
ActiveSupport::Concern
Included in:
Europeana::Blacklight::SearchBuilder
Defined in:
lib/europeana/blacklight/search_builder/more_like_this.rb

Overview

Search builder methods for more like this queries

Instance Method Summary collapse

Instance Method Details

#add_mlt_to_api(api_parameters) ⇒ Object



13
14
15
16
17
18
19
20
21
22
23
24
# File 'lib/europeana/blacklight/search_builder/more_like_this.rb', line 13

def add_mlt_to_api(api_parameters)
  return unless blacklight_params[:mlt]
  repository = blacklight_config.repository_class.new(blacklight_config)
  if blacklight_params[:mlt].respond_to?(:more_like_this_query)
    doc = blacklight_params[:mlt]
  else
    doc_response = repository.find(blacklight_params[:mlt])
    doc = doc_response.documents.first
  end
  query = doc.more_like_this_query(blacklight_params[:mltf])
  append_to_query_param(api_parameters, query)
end