ElasticSearch\tests\units\Client::testSlightlyComplexSearch PHP 메소드

testSlightlyComplexSearch() 공개 메소드

Test a midly complex search
    public function testSlightlyComplexSearch()
    {
        $client = \ElasticSearch\Client::connection();
        $uniqueWord = $this->getTag();
        $docs = 3;
        $doc = array('title' => "One cool document {$uniqueWord}", 'tag' => array('cool', "stuff", "2k"));
        while ($docs-- > 0) {
            $resp = $client->index($doc, false, array('refresh' => true));
        }
        $hits = $client->search(array('query' => array('bool' => array('must' => array('term' => array('title' => $uniqueWord)), 'should' => array('term' => array('tag' => 'stuff'))))));
        $this->assert->array($hits)->hasKey('hits')->array($hits['hits'])->hasKey('total')->integer($hits['hits']['total'])->isEqualTo(3);
    }