2

I'm using Solr 4.10.2 and Drupal 7.X, I have the Apache Solr Module Framework operating and sending the requests to Solr From Drupal. Currently when we perform a search, Drupal builds the query and sends it to Solr. Solr just executes the query and returns the results without using it's internal handlers which can be configured through SolrConfig.xml.

I would like to know if there is a way to just send the searched terms (without building a query) from Drupal and let Solr use the internal handlers declared in SolrConfig.xml to handle the request, build the query and then return the data?

The reason for this is we have been working on trying to boost some results when we perform a search (we want exact match first & fuzzy search results after) by changing the "weight" of some fields.

We know that from Back Office we can use the "Bias" function to boost some fields but this is too limited for what we are trying to achieve.

We also know we can change the query sent from Drupal directly from code side by using hook_apachesolr_modify_query() but we prefer changing as little code as possible and using the SolrConfig.xml /handlers which we already have configured to return the results as we want.

  • Note: I originally posted this in stackoverflow before realizing there is a Drupal community so I apologize for the double post (haven't checked stackexchange in a long time). – Loic O. Sep 16 '15 at 13:49
1

Ok, we figured out how to do this. In order to choose the handler that is being used by Solr while sending a request from Drupal, we have to edit hook_apachesolr_query_alter() and add the following code:

$query->addParam('qt', 'MyHandlerName');

We did some extra coding to allow us to change the handler directly from back office in order to be able to switch handlers without touching the code.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.