You are here

function apachesolr_drupal_query in Apache Solr Search 8

Same name and namespace in other branches
  1. 5.2 apachesolr.module \apachesolr_drupal_query()
  2. 5 apachesolr.module \apachesolr_drupal_query()
  3. 6.3 apachesolr.module \apachesolr_drupal_query()
  4. 6 apachesolr.module \apachesolr_drupal_query()
  5. 6.2 apachesolr.module \apachesolr_drupal_query()
  6. 7 apachesolr.module \apachesolr_drupal_query()

Factory function for query objects.

Parameters

string $name: The search name, used for finding the correct blocks and other config. Typically "apachesolr".

array $params: Array of params , such as 'q', 'fq' to be applied.

string $solrsort: Visible string telling solr how to sort.

string $base_path: The search base path (without the keywords) for this query.

DrupalApacheSolrServiceInterface $solr: An instance of DrupalApacheSolrServiceInterface.

Return value

DrupalSolrQueryInterface DrupalSolrQueryInterface object.

Throws

Exception

4 calls to apachesolr_drupal_query()
ApacheSolrFacetapiNumericRange::build in plugins/facetapi/query_type_numeric_range.inc
Initializes the facet's build array.
apachesolr_search_mlt_suggestions in ./apachesolr_search.module
Performs a moreLikeThis query using the settings and retrieves documents.
apachesolr_search_run in ./apachesolr_search.module
Execute a search results based on keyword, filter, and sort strings.
apachesolr_search_run_empty in ./apachesolr_search.module
Execute a search with zero results rows so as to populate facets.

File

./apachesolr.module, line 1604
Integration with the Apache Solr search application.

Code

function apachesolr_drupal_query($name, array $params = array(), $solrsort = '', $base_path = '', DrupalApacheSolrServiceInterface $solr = NULL, $context = array()) {
  if (!interface_exists('DrupalSolrQueryInterface')) {
    require_once dirname(__FILE__) . '/apachesolr.interface.inc';
  }
  $class_info = variable_get('apachesolr_query_class', array(
    'file' => 'Solr_Base_Query',
    'module' => 'apachesolr',
    'class' => 'SolrBaseQuery',
  ));
  $class = $class_info['class'];
  if (!class_exists($class_info['class']) && isset($class_info['file']) && isset($class_info['module'])) {
    module_load_include('php', $class_info['module'], $class_info['file']);
  }
  if (empty($solr)) {
    $solr = apachesolr_get_solr();
  }
  return new $class($name, $solr, $params, $solrsort, $base_path, $context);
}