예제 #1
0
 public function testRawQuery()
 {
     $textQuery = new Text();
     $textQuery->setField('title', 'test');
     $query1 = Query::create($textQuery);
     $query2 = new Query();
     $query2->setRawQuery(array('query' => array('text' => array('title' => 'test'))));
     $this->assertEquals($query1->toArray(), $query2->toArray());
 }
예제 #2
0
파일: TextTest.php 프로젝트: kskod/Elastica
 public function testTextPhrase()
 {
     $client = $this->_getClient();
     $index = $client->getIndex('test');
     $index->create(array(), true);
     $type = $index->getType('test');
     $doc = new Document(1, array('name' => 'Basel-Stadt'));
     $type->addDocument($doc);
     $doc = new Document(2, array('name' => 'New York'));
     $type->addDocument($doc);
     $doc = new Document(3, array('name' => 'New Hampshire'));
     $type->addDocument($doc);
     $doc = new Document(4, array('name' => 'Basel Land'));
     $type->addDocument($doc);
     $index->refresh();
     $type = 'text_phrase';
     $field = 'name';
     $query = new Text();
     $query->setFieldQuery($field, 'Basel New');
     $query->setField('operator', 'OR');
     $query->setFieldType($field, $type);
     $resultSet = $index->search($query);
     $this->assertEquals(4, $resultSet->count());
 }