Beispiel #1
0
 public function testShouldReturnTheRightNumberOfResult()
 {
     $f = new Elastica_Filter_Nested();
     $this->assertEquals(array('nested' => array()), $f->toArray());
     $q = new Elastica_Query_Terms();
     $q->setTerms('hobby', array('guitar'));
     $f->setPath('hobbies');
     $f->setQuery($q);
     $c = new Elastica_Client();
     $s = new Elastica_Search($c);
     $i = $c->getIndex('elastica_test_filter_nested');
     $s->addIndex($i);
     $r = $s->search($f);
     $this->assertEquals(1, $r->getTotalHits());
     $f = new Elastica_Filter_Nested();
     $this->assertEquals(array('nested' => array()), $f->toArray());
     $q = new Elastica_Query_Terms();
     $q->setTerms('hobby', array('opensource'));
     $f->setPath('hobbies');
     $f->setQuery($q);
     $c = new Elastica_Client();
     $s = new Elastica_Search($c);
     $i = $c->getIndex('elastica_test_filter_nested');
     $s->addIndex($i);
     $r = $s->search($f);
     $this->assertEquals(2, $r->getTotalHits());
 }
Beispiel #2
0
	public function testInvalidParams() {
		$query = new Elastica_Query_Terms();

		try {
			$query->toArray();
			$this->fail('Should throw exception because no key');
		} catch (Elastica_Exception_Invalid $e) {
			$this->assertTrue(true);
		}

	}