You are here

function apachesolr_search_type_boost_form in Apache Solr Search 6.3

Same name and namespace in other branches
  1. 8 apachesolr_search.admin.inc \apachesolr_search_type_boost_form()
  2. 5.2 apachesolr_search.admin.inc \apachesolr_search_type_boost_form()
  3. 6 apachesolr_search.admin.inc \apachesolr_search_type_boost_form()
  4. 6.2 apachesolr_search.admin.inc \apachesolr_search_type_boost_form()
  5. 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()
apachesolr_search_bias_form in ./apachesolr_search.admin.inc

File

./apachesolr_search.admin.inc, line 937
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 = node_get_types();
  foreach ($names as $type_id => $type) {
    $form['type_boost']['apachesolr_search_type_boosts'][$type_id] = array(
      '#type' => 'select',
      '#title' => t('%type type content bias', array(
        '%type' => $type->name,
      )),
      '#options' => $weights,
      '#default_value' => isset($type_boosts[$type_id]) ? $type_boosts[$type_id] : 0,
    );
  }
  return $form;
}