-
Notifications
You must be signed in to change notification settings - Fork 10
Solr and Blacklight Support
An effort has been made to provide methods in this gem to accept basic solr queries and to supply solr responses. This has been done so that the BlackLight EDS repository class can remain light weight and take advantage of many out-of-the box BlackLight defaults based on Solr.
Example:
results = session.search({'q' => 'volcano', 'start' => 0, 'rows' => 10, 'search_field' => 'title'})
results.to_solr
=> {"responseHeader"=>{"status"=>0, "QTime"=>119, "params"=>{"q"=>"volcano", "wt"=>"ruby", "start"=>0, "rows"=>10, "facet"=>true}}, "response"=>{"numFound"=>6744, "start"=>0, "docs"=>[{"id"=>"cat02060a__d_uga_4083378", "title_display"=>"Volcano. [electronic resource] : [nature and culture].", "academic_journal"=>"Volcano [electronic resource] : [nature and culture].", "pub_date"=>"2012", ...
Solr support includes: facets, search fields, sorting, spelling suggestions and highlighting.
Solr queries are supported via the Options class. The exception being that facets and limiters are optionally treated in the Session class when using the gem in a non-Solr context (see below).
Gem Query Parameter | Gem Example | Solr Equivalent | Solr Examples |
---|---|---|---|
query | query: 'climate change' |
q | 'q' => 'climate change' |
results_per_page | results_per_page: 15 |
per_page, rows | 'per_page' => '10' |
sort | sort: 'relevance' |
sort | 'sort'=>'pub_date_sort desc' |
highlight | highlight: 'n' |
hl | 'hl'=>'off' |
N/A - part of query | N/A | search_field |
'search_field'=>'all_fields' 'search_field'=>'author'
|
auto_correct | auto_correct: true |
auto_correct | 'auto_correct' => true |
auto_suggest | auto_suggest: true |
auto_suggest | 'auto_suggest' => true |
add_facet |
session.add_facet('ContentProvider', 'Government Printing Office Catalog') or 'f' => {'eds_content_provider_facet' => ['Government Printing Office Catalog']}
|
f | 'f' =>{'eds_publication_year_facet'=>['This year']} |
limiters | limiters: ['FT:Y', 'RV:Y'] |
f |
'f' => {'eds_search_limiters_facet'=>['Available in Library Collection', 'Full Text', 'Peer Reviewed']} or 'f' => {'eds_search_limiters_facet'=>['FT1', 'FT', 'RVC']},
|
For the detailed record page in Blacklight, it is desirable to only retrieve the current and next-previous records. In order to do this, add the previous-next-index
parameter to your search options, specifying the index of the current record:
session = EBSCO::EDS::Session.new({use_cache: false, profile: 'eds-api'})
opts = {
'f' =>
{'eds_language_facet' => ['spanish']},
'q' => 'white nose syndrome',
'search_field' => 'all_fields',
'controller' => 'catalog',
'action' => 'index',
'hl' => 'on',
'previous-next-index' => 1
}
results = session.solr_retrieve_previous_next(opts)
Full Solr example:
session = EBSCO::EDS::Session.new({use_cache: false, profile: 'eds-api'})
query = {
'f' => {
'eds_journal_facet'=>['new york times'],
'eds_subjects_geographic_facet'=>['united states'],
'eds_content_provider_facet'=>['Academic Search Ultimate'],
'eds_publication_year_facet'=>['Last 3 years']
},
'per_page'=>'10',
'sort'=>'pub_date_sort desc',
'q'=>'lincoln',
'search_field'=>'all_fields',
'controller'=>'catalog',
'action'=>'index',
'hl'=>'off' }
results = session.search(query)