src/Command/Elasticsearch.php
private function constructQueryBody(\ECL\SymbolTable $table, array $filters, \ECL\Command\Elasticsearch\Agg $agg=null, $fields=null, $sort=null, $size=null, $date_field=null, $from=null, $to=null) {
        $query_body = [
            'size' => 100,
            'query' => [
                'bool' => [
                    'filter' => $this->constructFilter(
                        $table, $filters, $date_field, $from, $to
                    )
                ]
            ]
        ];

        // Optionally set result set size.
        if(!is_null($size)) {
            $query_body['size'] = $size;
        }

        // Optionally set aggregations
        if(!is_null($agg)) {
            $query_body['aggs'] = $agg->constructQuery($table);
            // When executing an agg, we don't care about the actual hits.
            $query_body['size'] = 0;
        }

        // Optionally set list of fields to return.
        if(!is_null($fields)) {
            $query_body['_source'] = ['include' => $fields];
        }

        // Optionally set sort order.
        if(!is_null($sort)) {
            $query_body['sort'] = array_map(function($x) { return [$x[0] => ['order' => $x[1] ? 'asc':'desc']]; }, $sort);
        }

        return $query_body;
    }
private function constructQueryBody(\ECL\SymbolTable $table, array $filters, \ECL\Command\Elasticsearch\Agg $agg=null, $fields=null, $sort=null, $size=null, $date_field=null, $from=null, $to=null) {
        $query_body = [
            'size' => 100,
            'query' => [
                'bool' => [
                    'filter' => $this->constructFilter(
                        $table, $filters, $date_field, $from, $to
                    )
                ]
            ]
        ];

        // Optionally set result set size.
        if(!is_null($size)) {
            $query_body['size'] = $size;
        }

        // Optionally set aggregations
        if(!is_null($agg)) {
            $query_body['aggs'] = $agg->constructQuery($table);
            // When executing an agg, we don't care about the actual hits.
            $query_body['size'] = 0;
        }

        // Optionally set list of fields to return.
        if(!is_null($fields)) {
            $query_body['_source'] = ['include' => $fields];
        }

        // Optionally set sort order.
        if(!is_null($sort)) {
            $query_body['sort'] = array_map(function($x) { return [$x[0] => ['order' => $x[1] ? 'asc':'desc']]; }, $sort);
        }

        return $query_body;
    }
private function constructQueryBody ( \ ECL \ SymbolTable $ table , array $ filters , \ ECL \ Command \ Elasticsearch \ Agg $ agg = null , $ fields = null , $ sort = null , $ size = null , $ date_field = null , $ from = null , $ to = null ) { $ query_body = [ 'size' => 100 , 'query' => [ 'bool' => [ 'filter' => $ this -> constructFilter ( $ table , $ filters , $ date_field , $ from , $ to ) ] ] ] ; // Optionally set result set size. if ( ! is_null ( $ size ) ) { $ query_body [ 'size' ] = $ size ; } // Optionally set aggregations if ( ! is_null ( $ agg ) ) { $ query_body [ 'aggs' ] = $ agg -> constructQuery ( $ table ) ; // When executing an agg, we don't care about the actual hits. $ query_body [ 'size' ] = 0 ; } // Optionally set list of fields to return. if ( ! is_null ( $ fields ) ) { $ query_body [ '_source' ] = [ 'include' => $ fields ] ; } // Optionally set sort order. if ( ! is_null ( $ sort ) ) { $ query_body [ 'sort' ] = array_map ( function ( $ x ) { return [ $ x [ 0 ] => [ 'order' => $ x [ 1 ] ? 'asc' : 'desc' ] ] ; } , $ sort ) ; } return $ query_body ; }
Construct the query body.
Construct the query body .