You are here

function apachesolr_stats_determine_field_from_query in Apache Solr Statistics 6

Determine the facet field from a word: im_vid_XX, kw or XXX (anything before ":", like tid, uid, etc)

Return value

string The facet field id.

1 call to apachesolr_stats_determine_field_from_query()
apachesolr_stats_generate_report_elements in ./apachesolr_stats.module
Generates report elements for the given granularity.

File

./apachesolr_stats.module, line 566
Keeps and reports statistics about Apache Solr usage and performance.

Code

function apachesolr_stats_determine_field_from_query($facets, $word) {
  if (strpos($word, ":") !== false) {
    list($fieldname, $value) = explode(":", $word);
    if ($fieldname == "tid") {

      // Replace tid with the correct facet field name (im_vid_XXX) where XXX = vid
      $term = taxonomy_get_term(intval(substr($word, 4)));
      $fieldname = "im_vid_" . $term->vid;
    }
    else {

      // Check if $fieldname is really a facet, if not count as keyword
      if (empty($facets[$fieldname])) {
        $fieldname = false;
      }
    }
  }
  else {

    // No ":" found, so it's a keyword
    $fieldname = false;
  }
  return $fieldname;
}