
Untitled
By: a guest on
May 5th, 2012 | syntax:
PHP | size: 1.40 KB | hits: 36 | expires: Never
<?php
/**
* @file
*/
/**
*
* @param type $mappings
* @param type $entity_type
*/
function apachesolr_text_apachesolr_field_mappings_alter(&$mappings, $entity_type) {
// Enable indexing for text fields
$mappings['text'] = array(
'indexing_callback' => 'apachesolr_fields_default_indexing_callback',
'map callback' => '',
'index_type' => 'string',
'facets' => TRUE,
'facet missing allowed' => TRUE,
'dependency plugins' => array('bundle', 'role'),
'hierarchy callback' => FALSE,
'name_callback' => '',
'facet mincount allowed' => FALSE,
// Field API allows any field to be multi-valued.
// If we set this to false we are able to sort
//'multiple' => FALSE,
);
}
/**
* Prepare the query by adding parameters, sorts, etc.
*
* This hook is invoked before the query is cached. The cached query is used
* after the search such as for building facet and sort blocks, so parameters
* added during this hook may be visible to end users.
*
* This is otherwise the same as HOOK_apachesolr_query_alter(), but runs before
* it.
*
* @param object $query
* An object implementing DrupalSolrQueryInterface. No need for &.
*/
function apachesolr_text_apachesolr_query_prepare($query) {
// Add a sort on the node ID.
$query->setAvailableSort('its_field_year', array(
'title' => t('Year'),
'default' => 'asc',
));
}