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)


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

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.



6
7
8
# File 'app/models/blacklight_iiif_search/iiif_suggest_search.rb', line 6

def controller
  @controller
end

#document_idObject (readonly)

Returns the value of attribute document_id.



6
7
8
# File 'app/models/blacklight_iiif_search/iiif_suggest_search.rb', line 6

def document_id
  @document_id
end

#iiif_configObject (readonly)

Returns the value of attribute iiif_config.



6
7
8
# File 'app/models/blacklight_iiif_search/iiif_suggest_search.rb', line 6

def iiif_config
  @iiif_config
end

#paramsObject (readonly)

Returns the value of attribute params.



6
7
8
# File 'app/models/blacklight_iiif_search/iiif_suggest_search.rb', line 6

def params
  @params
end

#queryObject (readonly)

Returns the value of attribute query.



6
7
8
# File 'app/models/blacklight_iiif_search/iiif_suggest_search.rb', line 6

def query
  @query
end

#repositoryObject (readonly)

Returns the value of attribute repository.



6
7
8
# File 'app/models/blacklight_iiif_search/iiif_suggest_search.rb', line 6

def repository
  @repository
end

Instance Method Details

#responseIIIF::OrderedHash

Return the termList response

Returns:

  • (IIIF::OrderedHash)


25
26
27
28
# File 'app/models/blacklight_iiif_search/iiif_suggest_search.rb', line 25

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

#suggest_resultsRSolr::HashWithResponse

Query the suggest handler rubocop:disable Style/HashSyntax

Returns:

  • (RSolr::HashWithResponse)


34
35
36
37
38
# File 'app/models/blacklight_iiif_search/iiif_suggest_search.rb', line 34

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