public function get($conditions = [], $requiredField = [], $page = 0)
    {

        $searchParams['index'] = $this->index;
        $searchParams['type'] = $this->type;
        $searchParams['size'] = $this->maxResultsSize;
        $searchParams['from'] = $page * $this->maxResultsSize;
        $searchParams['body']['query']['bool']['must'] = [];
        $searchParams['_source_exclude']= ['PAG*'];

        $searchParams['body']['highlight']['order'] = 'score';
        $searchParams['body']['highlight']['fields'] = ['PAGE_*' => ['number_of_fragments' => 3], 'PAG_*' => ['number_of_fragments' => 3]];
        $searchParams['body']['highlight']['pre_tags'] = ['<strong>'];
        $searchParams['body']['highlight']['post_tags'] = ['</strong>'];

        foreach ($requiredField as $field) {
            $searchParams['body']['query']['bool']['must'][]['exists'] = ['field' => $field];
        }

        $filter = $this->makeFilterCondition($conditions);

        if(!empty($filter))$searchParams['body']['query']['bool']['must'][] = $filter;

        if($this->isModel)return $this->model->hydrateElasticsearchResult($this->client->search($searchParams));
        else return $this->client->search($searchParams);

    }
public function get($conditions = [], $requiredField = [], $page = 0)
    {

        $searchParams['index'] = $this->index;
        $searchParams['type'] = $this->type;
        $searchParams['size'] = $this->maxResultsSize;
        $searchParams['from'] = $page * $this->maxResultsSize;
        $searchParams['body']['query']['bool']['must'] = [];
        $searchParams['_source_exclude']= ['PAG*'];

        $searchParams['body']['highlight']['order'] = 'score';
        $searchParams['body']['highlight']['fields'] = ['PAGE_*' => ['number_of_fragments' => 3], 'PAG_*' => ['number_of_fragments' => 3]];
        $searchParams['body']['highlight']['pre_tags'] = ['<strong>'];
        $searchParams['body']['highlight']['post_tags'] = ['</strong>'];

        foreach ($requiredField as $field) {
            $searchParams['body']['query']['bool']['must'][]['exists'] = ['field' => $field];
        }

        $filter = $this->makeFilterCondition($conditions);

        if(!empty($filter))$searchParams['body']['query']['bool']['must'][] = $filter;

        if($this->isModel)return $this->model->hydrateElasticsearchResult($this->client->search($searchParams));
        else return $this->client->search($searchParams);

    }
public function get ( $ conditions = [ ] , $ requiredField = [ ] , $ page = 0 ) { $ searchParams [ 'index' ] = $ this -> index ; $ searchParams [ 'type' ] = $ this -> type ; $ searchParams [ 'size' ] = $ this -> maxResultsSize ; $ searchParams [ 'from' ] = $ page * $ this -> maxResultsSize ; $ searchParams [ 'body' ] [ 'query' ] [ 'bool' ] [ 'must' ] = [ ] ; $ searchParams [ '_source_exclude' ] = [ 'PAG*' ] ; $ searchParams [ 'body' ] [ 'highlight' ] [ 'order' ] = 'score' ; $ searchParams [ 'body' ] [ 'highlight' ] [ 'fields' ] = [ 'PAGE_*' => [ 'number_of_fragments' => 3 ] , 'PAG_*' => [ 'number_of_fragments' => 3 ] ] ; $ searchParams [ 'body' ] [ 'highlight' ] [ 'pre_tags' ] = [ '<strong>' ] ; $ searchParams [ 'body' ] [ 'highlight' ] [ 'post_tags' ] = [ '</strong>' ] ; foreach ( $ requiredField as $ field ) { $ searchParams [ 'body' ] [ 'query' ] [ 'bool' ] [ 'must' ] [ ] [ 'exists' ] = [ 'field' => $ field ] ; } $ filter = $ this -> makeFilterCondition ( $ conditions ) ; if ( ! empty ( $ filter ) ) $ searchParams [ 'body' ] [ 'query' ] [ 'bool' ] [ 'must' ] [ ] = $ filter ; if ( $ this -> isModel ) return $ this -> model -> hydrateElasticsearchResult ( $ this -> client -> search ( $ searchParams ) ) ; else return $ this -> client -> search ( $ searchParams ) ; }
Search from condition function

@param array $conditions
@param array $requiredField Es. ['DOCUMENT_SIZE', 'DOCUMENT_CODE', 'SITE_CODE', 'SITE_NAME', 'TOWN_CITY_NAME'];
@param int $page
@return mixed
@throws \Exception
Search from condition function