public static function searchByQuery($query = null, $aggregations = null, $sourceFields = null, $limit = null, $offset = null, $sort = null)
    {
        $instance = new static;

        $params = $instance->getBasicEsParams(true, true, true, $limit, $offset);

        if ($sourceFields) {
            $params['body']['_source']['include'] = $sourceFields;
        }

        if ($query) {
            $params['body']['query'] = $query;
        }

        if ($aggregations) {
            $params['body']['aggs'] = $aggregations;
        }
        
        if ($sort) {
            $params['body']['sort'] = $sort;
        }

        $result = $instance->getElasticSearchClient()->search($params);

        return new ResultCollection($result, $instance = new static);
    }
public static function searchByQuery($query = null, $aggregations = null, $sourceFields = null, $limit = null, $offset = null, $sort = null)
    {
        $instance = new static;

        $params = $instance->getBasicEsParams(true, true, true, $limit, $offset);

        if ($sourceFields) {
            $params['body']['_source']['include'] = $sourceFields;
        }

        if ($query) {
            $params['body']['query'] = $query;
        }

        if ($aggregations) {
            $params['body']['aggs'] = $aggregations;
        }
        
        if ($sort) {
            $params['body']['sort'] = $sort;
        }

        $result = $instance->getElasticSearchClient()->search($params);

        return new ResultCollection($result, $instance = new static);
    }
public static function searchByQuery ( $ query = null , $ aggregations = null , $ sourceFields = null , $ limit = null , $ offset = null , $ sort = null ) { $ instance = new static ; $ params = $ instance -> getBasicEsParams ( true , true , true , $ limit , $ offset ) ; if ( $ sourceFields ) { $ params [ 'body' ] [ '_source' ] [ 'include' ] = $ sourceFields ; } if ( $ query ) { $ params [ 'body' ] [ 'query' ] = $ query ; } if ( $ aggregations ) { $ params [ 'body' ] [ 'aggs' ] = $ aggregations ; } if ( $ sort ) { $ params [ 'body' ] [ 'sort' ] = $ sort ; } $ result = $ instance -> getElasticSearchClient ( ) -> search ( $ params ) ; return new ResultCollection ( $ result , $ instance = new static ) ; }
Search By Query

Search with a query array

@param   array $query
@param   array $aggregations
@param   array $sourceFields
@param   int $limit
@param   int $offset
@return  ResultCollection
Search By Query