You are here

function apachesolr_common_node_facets in Apache Solr Search 8

Same name and namespace in other branches
  1. 6.3 apachesolr.module \apachesolr_common_node_facets()
  2. 7 apachesolr.module \apachesolr_common_node_facets()

Helper function returning common facet definitions.

1 call to apachesolr_common_node_facets()
apachesolr_default_node_facet_info in ./apachesolr.module
Returns an array of facets for node fields and attributes.

File

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

Code

function apachesolr_common_node_facets() {
  $facets['bundle'] = array(
    'label' => t('Content type'),
    'description' => t('Filter by content type.'),
    'field api bundles' => array(
      'node',
    ),
    'map callback' => 'facetapi_map_bundle',
    'values callback' => 'facetapi_callback_type_values',
    'facet mincount allowed' => TRUE,
    'dependency plugins' => array(
      'role',
    ),
  );
  $facets['author'] = array(
    'label' => t('Author'),
    'description' => t('Filter by author.'),
    'field' => 'is_uid',
    'map callback' => 'facetapi_map_author',
    'values callback' => 'facetapi_callback_user_values',
    'facet mincount allowed' => TRUE,
    'dependency plugins' => array(
      'bundle',
      'role',
    ),
  );
  $facets['language'] = array(
    'label' => t('Language'),
    'description' => t('Filter by language.'),
    'field' => 'ss_language',
    'map callback' => 'facetapi_map_language',
    'values callback' => 'facetapi_callback_language_values',
    'facet mincount allowed' => TRUE,
    'dependency plugins' => array(
      'bundle',
      'role',
    ),
  );
  $facets['created'] = array(
    'label' => t('Post date'),
    'description' => t('Filter by the date the node was posted.'),
    'field' => 'ds_created',
    'query types' => array(
      'date',
    ),
    'allowed operators' => array(
      FACETAPI_OPERATOR_AND => TRUE,
    ),
    'map callback' => 'facetapi_map_date',
    'min callback' => 'facetapi_get_min_date',
    'max callback' => 'facetapi_get_max_date',
    'dependency plugins' => array(
      'bundle',
      'role',
    ),
    'default sorts' => array(
      array(
        'active',
        SORT_DESC,
      ),
      array(
        'indexed',
        SORT_ASC,
      ),
    ),
  );
  $facets['changed'] = array(
    'label' => t('Updated date'),
    'description' => t('Filter by the date the node was last modified.'),
    'field' => 'ds_changed',
    'query types' => array(
      'date',
    ),
    'allowed operators' => array(
      FACETAPI_OPERATOR_AND => TRUE,
    ),
    'map callback' => 'facetapi_map_date',
    'min callback' => 'facetapi_get_min_date',
    'max callback' => 'facetapi_get_max_date',
    'dependency plugins' => array(
      'bundle',
      'role',
    ),
    'default sorts' => array(
      array(
        'active',
        SORT_DESC,
      ),
      array(
        'indexed',
        SORT_ASC,
      ),
    ),
  );
  if (module_exists('book')) {
    $facets['book'] = array(
      'label' => t('Book'),
      'description' => t('Filter by the book that the node belongs to.'),
      'field' => 'is_book_bid',
      'map callback' => 'apachesolr_map_book',
      'facet mincount allowed' => TRUE,
      'dependency plugins' => array(
        'bundle',
        'role',
      ),
    );
  }
  return $facets;
}