Last active
November 4, 2015 04:06
-
-
Save algotrader-dotcom/b558483371b05ca4b872 to your computer and use it in GitHub Desktop.
Drupal 7: Alter apache solr query with custom module
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # 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