Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Select an option

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

Select an option

Save algotrader-dotcom/6b03095d74851b2e4489 to your computer and use it in GitHub Desktop.
Drupal 7: Apache solr search programtically
# Create file solr-test.php
<?php
define('DRUPAL_ROOT', '/home/vhosts/domain.com');
require_once DRUPAL_ROOT . '/includes/bootstrap.inc';
drupal_bootstrap(DRUPAL_BOOTSTRAP_FULL);
$q = 'label:nhan vien kinh doanh '.'AND'.' sm_field_location:ha noi';
$query = apachesolr_drupal_query(); // Get current solr query object
$query->addParam(q, $q);
$response = apachesolr_do_query($query); // Do search with query
print_r($response);
?>
References
http://www.paulbooker.co.uk/drupal-developer/code-snippet/solr-query-find-related-nodes-other-content-types-similar-taxonomies
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment