Exemple #1
0
 /**
  * Create a new facetQuery.
  *
  * Convenience method so you don't need to manually create facetquery
  * objects.
  *
  * @param string $key
  * @param string $query
  * @param array  $excludes
  *
  * @return self Provides fluent interface
  */
 public function createQuery($key, $query, $excludes = array())
 {
     // merge excludes with shared excludes
     $excludes = array_merge($this->getExcludes(), $excludes);
     $facetQuery = new Query();
     $facetQuery->setKey($key);
     $facetQuery->setQuery($query);
     $facetQuery->setExcludes($excludes);
     return $this->addQuery($facetQuery);
 }
Exemple #2
0
 public function testSetFacets()
 {
     $fq1 = new FacetQuery();
     $fq1->setKey('f1')->setQuery('category:1');
     $fq2 = new FacetQuery();
     $fq2->setKey('f2')->setQuery('category:2');
     $facets = array('f1' => $fq1, 'f2' => $fq2);
     $this->facetSet->addFacets($facets);
     $fq3 = new FacetQuery();
     $fq3->setKey('f3')->setQuery('category:3');
     $fq4 = new FacetQuery();
     $fq4->setKey('f4')->setQuery('category:4');
     $facets = array('f3' => $fq3, 'f4' => $fq4);
     $this->facetSet->setFacets($facets);
     $this->assertEquals($facets, $this->facetSet->getFacets());
 }
 public function testClearExcludesForwarding()
 {
     $this->facet->addExclude('fq1');
     $this->facet->addExclude('fq2');
     $facetQuery = new Query();
     $facetQuery->setKey('k1');
     $facetQuery->setQuery('category:1');
     $this->facet->addQuery($facetQuery);
     $this->assertEquals(array('fq1', 'fq2'), $facetQuery->getExcludes());
     $this->facet->clearExcludes();
     $this->assertEquals(array(), $facetQuery->getExcludes());
 }