Re: [Blacklight-development] Additional solr index searches without using blacklight helper

41 views
Skip to first unread message

Justin Coyne

unread,
Aug 4, 2023, 2:52:17 PM8/4/23
to blacklight-...@googlegroups.com
Hello Tadas. Can you explain what you mean by "hook into the search helper". I'm not sure that's enough detail to provide a technically detailed answer.

-Justin

On Thu, Aug 3, 2023 at 9:57 AM Tadas Paegle <tpa...@iu.edu> wrote:
Hi,
We are currently in the process of upgrading the Indiana University iucat.iu.edu from Blacklight 6.2 -> Blacklight 7.33.1. We've managed to get quite a bit working but are not sure how to approach our "extra searches" like music/reserves/lilly  which use different solr indexes than our main search catalog index. 

Currently we hook into the search helper, which no longer exists and override to use our own "repository" methods

Any clues would be great! 
Tadas 

--
You received this message because you are subscribed to the Google Groups "Blacklight Development" group.
To unsubscribe from this group and stop receiving emails from it, send an email to blacklight-develo...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/blacklight-development/1a8b354f-26e2-4e71-9e45-8c05878ae8a0n%40googlegroups.com.

Tadas Paegle

unread,
Aug 4, 2023, 3:26:00 PM8/4/23
to Blacklight Development
Hi Justin, 
The original developers are no longer working with us but they created separate gems for each solr core
Currently we call the blacklight6 search_results method  in blacklight_search_helper from our controller, which uses our own "repository" method for repository.search(builderand points to a different core. 
Here is some code from our music search gem.   In the routes file we have 
mount MusicSearch::Engineat'music'

Thanks, 
Tadas 
 
module MusicSearch::SolrHelperExtension
extend ActiveSupport::Concern
include Blacklight::SearchHelper

def repository
MusicSearch::SolrRepository.new(blacklight_config)
end
end



class MusicsearchController ApplicationController
include MusicSearch::SolrHelperExtension
include BlacklightRangeLimit::ControllerOverride
include BlacklightAdvancedSearch::Controller
include Blacklight::Catalog
include Blacklight::Marc::Catalog
include Blacklight::Controller
include Blacklight::Folders::ApplicationControllerBehavior

###
config. stuff
###

def index
session[:view] = 'music'

# Save the current search path into a session variable
# - This is necessary for back_to_search links to work on Reserves details views
if params['q']
session[:search_results_url] = request.url
end

(@response@document_list) = search_results params

# music_response_facets

respond_to do |format|
format.html {
if params[:q# search executed
render '/catalog/index'
else
render '/music_search/home'
end
}
format.rss { render :layout => false }
format.atom { render :layout => false }
format.json do
render json: render_search_results_as_json
end

additional_response_formats(format)
document_export_formats(format)
end

end





module MusicSearch
class SolrRepository Blacklight::Solr::Repository
def build_connection
@blacklight_solr ||= RSolr.connect(blacklight_solr_config)
end

def blacklight_solr_config
   @blacklight_solr_config ||= Rails.application.config.music_search_solr_config
end
end
end

Justin Coyne

unread,
Aug 4, 2023, 5:30:32 PM8/4/23
to blacklight-...@googlegroups.com
In blacklight 7.0.0.rc1 we introduced `search_service` https://github.com/projectblacklight/blacklight/commit/3aa964bf9f9911e5fd3f594c214a7afa115790e9 you might want to look at having a different search_service_class for each context you are in https://github.com/projectblacklight/blacklight/blob/v7.0.0/app/controllers/concerns/blacklight/controller.rb#L34-L37

I hope this is helpful.

Cheers,
Justin

Tadas Paegle

unread,
Aug 4, 2023, 5:48:38 PM8/4/23
to blacklight-...@googlegroups.com
Yeah, we are using the search service class for the main catalog search,  I'll try the separate classes idea 

Thanks,
Tadas  

Reply all
Reply to author
Forward
0 new messages