Elastica\Type::search PHP Method

    public function search($query = '', $options = null)
    {
        $search = $this->createSearch($query, $options);
        return $search->search();
    }

Usage Example

 public function testSearch()
 {
     $client = $this->_getClient();
     $index = new Index($client, 'test');
     $index->create(array(), true);
     $type = new Type($index, 'helloworld');
     $doc = new Document(1, array('id' => 1, 'email' => '*****@*****.**', 'username' => 'hans', 'test' => array('2', '3', '5')));
     $type->addDocument($doc);
     $doc = new Document(2, array('id' => 2, 'email' => '*****@*****.**', 'username' => 'emil', 'test' => array('1', '3', '6')));
     $type->addDocument($doc);
     $doc = new Document(3, array('id' => 3, 'email' => '*****@*****.**', 'username' => 'ruth', 'test' => array('2', '3', '7')));
     $type->addDocument($doc);
     // Refresh index
     $index->refresh();
     $boolQuery = new Bool();
     $termQuery1 = new Term(array('test' => '2'));
     $boolQuery->addMust($termQuery1);
     $resultSet = $type->search($boolQuery);
     $this->assertEquals(2, $resultSet->count());
     $termQuery2 = new Term(array('test' => '5'));
     $boolQuery->addMust($termQuery2);
     $resultSet = $type->search($boolQuery);
     $this->assertEquals(1, $resultSet->count());
     $termQuery3 = new Term(array('username' => 'hans'));
     $boolQuery->addMust($termQuery3);
     $resultSet = $type->search($boolQuery);
     $this->assertEquals(1, $resultSet->count());
     $termQuery4 = new Term(array('username' => 'emil'));
     $boolQuery->addMust($termQuery4);
     $resultSet = $type->search($boolQuery);
     $this->assertEquals(0, $resultSet->count());
 }
All Usage Examples Of Elastica\Type::search