You are here

public function GoogleMini::addMetaDataFilter in Google Search Appliance 5

Same name and namespace in other branches
  1. 6.2 GoogleMini.php \GoogleMini::addMetaDataFilter()

Adds a meta data filter to the query. Currently has limited flexibility. Pass a key as a meta field and values as an array of values to be OR'd together. or you can pass a value as a string to be the only value (for ease of use).

When you filter on many fields they are all AND'd together.

Parameters

fieldname $key:

string|array $values:

type either requiredfields or partialfields:

string $join either AND or OR:

File

./GoogleMini.php, line 69

Class

GoogleMini

Code

public function addMetaDataFilter($key, $values, $type = 'partialfields', $join = 'OR') {
  if (!in_array($type, array(
    'partialfields',
    'requiredfields',
  ))) {
    throw new GoogleMiniCriteriaException("You must provide a type of either partialfields or requiredfields", '-99');
  }
  if (is_array($values)) {
    $this->_metaDataFilters[$type][$key] = new stdClass();
    $this->_metaDataFilters[$type][$key]->type = $join;
    foreach ($values as $k => $value) {
      $this->_metaDataFilters[$type][$key]->values[] = urlencode($value);
    }
  }
  else {
    $this->_metaDataFilters[$type][$key]->type = $join;
    $this->_metaDataFilters[$type][$key]->values = array(
      urlencode($values),
    );
  }
}