You are here

protected function SolrBaseQuery::addFq in Apache Solr Search 7

Same name and namespace in other branches
  1. 8 Solr_Base_Query.php \SolrBaseQuery::addFq()
  2. 6.3 Solr_Base_Query.php \SolrBaseQuery::addFq()
1 call to SolrBaseQuery::addFq()
SolrBaseQuery::addParam in ./Solr_Base_Query.php
Adds a param to be sent when running the Solr search.

File

./Solr_Base_Query.php, line 473
This class allows you to make operations on a query that will be sent to Apache Solr. methods such as adding and removing sorts, remove and replace parameters, adding and removing filters, getters and setters for various parameters and more

Class

SolrBaseQuery

Code

protected function addFq($string, $index = NULL) {
  $string = trim($string);
  $local = '';
  $exclude = FALSE;
  $name = NULL;
  $value = NULL;
  $matches = array();

  // Check if we are dealing with an exclude
  if (preg_match('/^-(.*)/', $string, $matches)) {
    $exclude = TRUE;
    $string = $matches[1];
  }

  // If {!something} is found as first character then this is a local value
  if (preg_match('/\\{!([^}]+)\\}(.*)/', $string, $matches)) {
    $local = $matches[1];
    $string = $matches[2];
  }

  // Anything that has a name and value
  // check if we have a : in the string
  if (strstr($string, ':')) {
    list($name, $value) = explode(":", $string, 2);
  }
  else {
    $value = $string;
  }
  $this
    ->addFilter($name, $value, $exclude, $local);
  return $this;
}