Class: BlacklightIiifSearch::IiifSuggestSearch

Inherits:
Object
  • Object
show all
Defined in:
app/models/blacklight_iiif_search/iiif_suggest_search.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(params, repository, controller) ⇒ IiifSuggestSearch

Returns a new instance of IiifSuggestSearch.

Parameters:

  • params (Hash)
  • repository (Blacklight::AbstractRepository)
  • controller (CatalogController)


11
12
13
14
15
16
17
18
# File 'app/models/blacklight_iiif_search/iiif_suggest_search.rb', line 11

def initialize(params, repository, controller)
  @params = params
  @query = params[:q]
  @document_id = params[:solr_document_id]
  @iiif_config = controller.iiif_search_config
  @repository = repository
  @controller = controller
end

Instance Attribute Details

#controllerObject (readonly)

Returns the value of attribute controller.



4
5
6
# File 'app/models/blacklight_iiif_search/iiif_suggest_search.rb', line 4

def controller
  @controller
end

#document_idObject (readonly)

Returns the value of attribute document_id.



4
5
6
# File 'app/models/blacklight_iiif_search/iiif_suggest_search.rb', line 4

def document_id
  @document_id
end

#iiif_configObject (readonly)

Returns the value of attribute iiif_config.



4
5
6
# File 'app/models/blacklight_iiif_search/iiif_suggest_search.rb', line 4

def iiif_config
  @iiif_config
end

#paramsObject (readonly)

Returns the value of attribute params.



4
5
6
# File 'app/models/blacklight_iiif_search/iiif_suggest_search.rb', line 4

def params
  @params
end

#queryObject (readonly)

Returns the value of attribute query.



4
5
6
# File 'app/models/blacklight_iiif_search/iiif_suggest_search.rb', line 4

def query
  @query
end

#repositoryObject (readonly)

Returns the value of attribute repository.



4
5
6
# File 'app/models/blacklight_iiif_search/iiif_suggest_search.rb', line 4

def repository
  @repository
end

Instance Method Details

#responseIIIF::OrderedHash

Return the termList response

Returns:

  • (IIIF::OrderedHash)


23
24
25
26
# File 'app/models/blacklight_iiif_search/iiif_suggest_search.rb', line 23

def response
  response = IiifSuggestResponse.new(suggest_results, params, controller)
  response.term_list
end

#suggest_resultsRSolr::HashWithResponse

Query the suggest handler

Returns:

  • (RSolr::HashWithResponse)


31
32
33
34
35
# File 'app/models/blacklight_iiif_search/iiif_suggest_search.rb', line 31

def suggest_results
  suggest_params = { q: query, :'suggest.cfq' => document_id }
  repository.connection.send_and_receive(iiif_config[:autocomplete_handler],
                                         params: suggest_params)
end