You are here

function apachesolr_search_mlt_get_fields in Apache Solr Search 7

Same name and namespace in other branches
  1. 8 apachesolr_search.admin.inc \apachesolr_search_mlt_get_fields()
  2. 6.3 apachesolr_search.admin.inc \apachesolr_search_mlt_get_fields()

Constructs a list of field names used on the settings form. TODO: This always assumes the default environment!

Return value

array An array containing a the fields in the solr instance.

1 call to apachesolr_search_mlt_get_fields()
apachesolr_search_mlt_block_form in ./apachesolr_search.admin.inc
Form to edit moreLikeThis block settings.

File

./apachesolr_search.admin.inc, line 981
Administrative settings for searching.

Code

function apachesolr_search_mlt_get_fields() {
  $rows = array();
  $env_id = apachesolr_default_environment();
  try {
    $solr = apachesolr_get_solr($env_id);
    $fields = $solr
      ->getFields();
    foreach ($fields as $field_name => $field) {

      // 'V' appears in different positions in different Solr versions.
      if (strpos($field->schema, 'V') !== FALSE) {
        $rows[$field_name] = apachesolr_field_name_map($field_name);
      }
    }
    ksort($rows);
  } catch (Exception $e) {
    apachesolr_log_exception($env_id, $e);
  }
  return $rows;
}