You are here

function apachesolr_search_mlt_get_fields in Apache Solr Search 8

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

Constructs a list of field names used on the settings form.

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 969
Administrative settings for searching.

Code

function apachesolr_search_mlt_get_fields() {
  $rows = array();
  try {
    $solr = apachesolr_get_solr();
    $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) {
    watchdog('Apache Solr', nl2br(check_plain($e
      ->getMessage())), NULL, WATCHDOG_ERROR);
  }
  return $rows;
}