Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Select an option

  • Save algotrader-dotcom/b558483371b05ca4b872 to your computer and use it in GitHub Desktop.

Select an option

Save algotrader-dotcom/b558483371b05ca4b872 to your computer and use it in GitHub Desktop.
Drupal 7: Alter apache solr query with custom module
# Add the following function in MyModule to override $query solr object
# This will change q param to sm_field_location:ha noi
function mymodule_apachesolr_query_alter(DrupalSolrQueryInterface $query) {
// print_r($query)
// print $query->getParam('q');
$query->replaceParam('q', 'sm_field_location:ha noi');
print $query->getParam('q');
//print $query->q;
}
# Notes: sm_field_location must be indexed to be allowed field query first
References:
http://findsupport.xyz/question/27039724/solr-search-in-multiple-fields-in-drupal-7
https://gist.github.com/thuannvn/82c2166dcfc000bc5d5b
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment