function apachesolr_search_type_boost_form in Apache Solr Search 8
Same name and namespace in other branches
- 5.2 apachesolr_search.admin.inc \apachesolr_search_type_boost_form()
- 6.3 apachesolr_search.admin.inc \apachesolr_search_type_boost_form()
- 6 apachesolr_search.admin.inc \apachesolr_search_type_boost_form()
- 6.2 apachesolr_search.admin.inc \apachesolr_search_type_boost_form()
- 7 apachesolr_search.admin.inc \apachesolr_search_type_boost_form()
Form builder function to set query type weights.
1 call to apachesolr_search_type_boost_form()
File
- ./
apachesolr_search.admin.inc, line 880 - Administrative settings for searching.
Code
function apachesolr_search_type_boost_form($env_id) {
$form['type_boost'] = array(
'#type' => 'fieldset',
'#title' => t('Type biasing'),
'#collapsible' => TRUE,
'#collapsed' => FALSE,
'#group' => 'bias_tabs',
);
$form['type_boost']['apachesolr_search_type_boosts'] = array(
'#type' => 'item',
'#description' => t("Specify here which node types should get a higher relevancy score in searches. Any value except <em>Ignore</em> will increase the score of the given type in search results."),
'#tree' => TRUE,
);
$weights = drupal_map_assoc(array(
'21.0',
'13.0',
'8.0',
'5.0',
'3.0',
'2.0',
'1.0',
'0.8',
'0.5',
'0.3',
'0.2',
'0.1',
));
$weights['0'] = t('Ignore');
// Get the current boost values.
$type_boosts = apachesolr_environment_variable_get($env_id, 'apachesolr_search_type_boosts', array());
$names = array();
foreach (entity_get_info() as $entity_type => $entity_info) {
if (!empty($entity_info['apachesolr']['indexable'])) {
foreach ($entity_info['bundles'] as $key => $info) {
$names[$key] = $info['label'];
}
}
}
asort($names);
foreach ($names as $type => $name) {
$form['type_boost']['apachesolr_search_type_boosts'][$type] = array(
'#type' => 'select',
'#title' => t('%type type content bias', array(
'%type' => $name,
)),
'#options' => $weights,
'#default_value' => isset($type_boosts[$type]) ? $type_boosts[$type] : 0,
);
}
return $form;
}