Author: Lee Parker
Author: Nicolas Ruflin (spam@ruflin.com)
Author: Tim Rupp
Inheritance: extends AbstractQuery
示例#1
0
 /**
  * @group unit
  */
 public function testToArrayWithLegacyFilter()
 {
     $query = new BoolQuery();
     $idsQuery1 = new Ids();
     $idsQuery1->setIds(1);
     $idsQuery2 = new Ids();
     $idsQuery2->setIds(2);
     $idsQuery3 = new Ids();
     $idsQuery3->setIds(3);
     $this->hideDeprecated();
     $filter1 = new TermFilter();
     $filter1->setTerm('test', '1');
     $filter2 = new TermFilter();
     $filter2->setTerm('username', 'ruth');
     $this->showDeprecated();
     $boost = 1.2;
     $minMatch = 2;
     $query->setBoost($boost);
     $query->setMinimumNumberShouldMatch($minMatch);
     $query->addMust($idsQuery1);
     $query->addMustNot($idsQuery2);
     $query->addShould($idsQuery3->toArray());
     $this->hideDeprecated();
     $query->addFilter($filter1);
     $query->addFilter($filter2);
     $this->showDeprecated();
     $expectedArray = array('bool' => array('must' => array($idsQuery1->toArray()), 'should' => array($idsQuery3->toArray()), 'filter' => array($filter1->toArray(), $filter2->toArray()), 'minimum_number_should_match' => $minMatch, 'must_not' => array($idsQuery2->toArray()), 'boost' => $boost));
     $this->assertEquals($expectedArray, $query->toArray());
 }
示例#2
0
 /**
  * @group unit
  */
 public function testToArray()
 {
     $query = new BoolQuery();
     $idsQuery1 = new Ids();
     $idsQuery1->setIds(1);
     $idsQuery2 = new Ids();
     $idsQuery2->setIds(2);
     $idsQuery3 = new Ids();
     $idsQuery3->setIds(3);
     $boost = 1.2;
     $minMatch = 2;
     $query->setBoost($boost);
     $query->setMinimumNumberShouldMatch($minMatch);
     $query->addMust($idsQuery1);
     $query->addMustNot($idsQuery2);
     $query->addShould($idsQuery3->toArray());
     $expectedArray = array('bool' => array('must' => array($idsQuery1->toArray()), 'should' => array($idsQuery3->toArray()), 'minimum_number_should_match' => $minMatch, 'must_not' => array($idsQuery2->toArray()), 'boost' => $boost));
     $this->assertEquals($expectedArray, $query->toArray());
 }
示例#3
0
 /**
  * @group unit
  */
 public function testToArray()
 {
     $query = new DisMax();
     $idsQuery1 = new Ids();
     $idsQuery1->setIds(1);
     $idsQuery2 = new Ids();
     $idsQuery2->setIds(2);
     $idsQuery3 = new Ids();
     $idsQuery3->setIds(3);
     $boost = 1.2;
     $tieBreaker = 2;
     $query->setBoost($boost);
     $query->setTieBreaker($tieBreaker);
     $query->addQuery($idsQuery1);
     $query->addQuery($idsQuery2);
     $query->addQuery($idsQuery3->toArray());
     $expectedArray = array('dis_max' => array('tie_breaker' => $tieBreaker, 'boost' => $boost, 'queries' => array($idsQuery1->toArray(), $idsQuery2->toArray(), $idsQuery3->toArray())));
     $this->assertEquals($expectedArray, $query->toArray());
 }
示例#4
0
 /**
  * @group functional
  */
 public function testSetTypeArraySearchSingle()
 {
     $query = new Ids();
     $query->setIds('4');
     $query->setType(array('helloworld1', 'helloworld2'));
     $resultSet = $this->_index->search($query);
     $this->assertEquals(1, $resultSet->count());
 }
示例#5
0
文件: Quips.php 项目: bd808/quips
 /**
  * Get a quip
  *
  * @param string $id
  * @return ResultSet
  */
 public function getQuip($id)
 {
     $ids = new Ids();
     $ids->setIds($id);
     $query = new Query($ids);
     $query->setFrom(0)->setSize(1)->setFields($this->defaultFields());
     return $this->doSearch($query);
 }
示例#6
0
文件: Logs.php 项目: bd808/SAL
 /**
  * Get a log
  *
  * @param string $id
  * @return ResultSet
  */
 public function getLog($id)
 {
     $ids = new Ids();
     $ids->setIds($id);
     $query = new Query($ids);
     $query->setFrom(0)->setSize(1)->setFields(self::$DEFAULT_FIELDS);
     return $this->doSearch($query);
 }