Hello Everyone! I have 2 questions that I would like to ask the community. We currently have our Blacklight instance up and running with our values indexed into Solr and displaying. What I'm trying to do is access our Solr index values from the catalog_controller. So for example, if one of our indexed values is 'language_term_t' (which is being displayed in the config.add_show_field) and I wanted to perform an operation like:
if langauge_term_t == 'English'
Is there a way to do this from the catalog_controller? I tried to use config.search_fields.values.select { 'langauge_term_t'}) =='English' but that didn't work.
My second question is how to perform a customized Solr query? What I did was follow the example for the 'default_document_solr_params' hash. I created a empty hash in configuration.rb called
:solr_child_field => {}. I then constructed two methods in the solr_helper.rb file like so:
def solr_doc_child_params(id=nil)
id ||= params[:id]
p = blacklight_config.solr_child_field.merge({
:id => id # this assumes the document request handler will map the 'id' param to the unique key field
})
p[:qt] ||= 'document'
p
end
def get_solr_response_for_child_id(id=nil, extra_controller_params={})
solr_params = solr_doc_child_params(id).merge(extra_controller_params)
solr_response = find((blacklight_config.document_solr_request_handler || blacklight_config.qt), solr_params)
raise Blacklight::Exceptions::InvalidSolrID.new if solr_response.docs.empty?
document = SolrDocument.new(solr_response.docs.first, solr_response)
[solr_response, document]
end
With 'solr_doc_child_params' method mirroring the 'solr_doc_params' method and the 'get_solr_response_for_child_id' method mirroring the 'get_solr_response_for_doc_id' method. I then called the method in the 'show' method of the catalog.rb file right below the 'get_solr_response_for_doc_id' method like so:
@response, @document = get_solr_response_for_doc_id
@response, @document = get_solr_response_for_child_id
Then in the catalog_controller I populate the hash by using:
config.solr_child_field = {
:fl => 'id,display_label_s,zindex_i'
}
However, nothing happens. But if I use the default_document_solr_params hash, the values appear. I know this is a very specific question, but can someone please point out what I'm doing wrong or what I'm missing? Or maybe this isn't the right path to go for creating a customized Solr query and it could be done simpler? Thanks,
-Lakeisha Robinson-
Yale University