You are here

protected function SolrBaseQuery::addFq in Apache Solr Search 8

Same name and namespace in other branches
  1. 6.3 Solr_Base_Query.php \SolrBaseQuery::addFq()
  2. 7 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 433
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;

  // 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;
}