yii\elasticsearch\QueryBuilder::buildHalfBoundedRangeCondition PHP Method

buildHalfBoundedRangeCondition() private method

Builds a half-bounded range condition (for "gt", ">", "gte", ">=", "lt", "<", "lte", "<=" operators)
private buildHalfBoundedRangeCondition ( string $operator, array $operands ) : array
$operator string
$operands array
return array Filter expression
    private function buildHalfBoundedRangeCondition($operator, $operands)
    {
        if (!isset($operands[0], $operands[1])) {
            throw new InvalidParamException("Operator '{$operator}' requires two operands.");
        }
        list($column, $value) = $operands;
        if ($column == '_id') {
            $column = '_uid';
        }
        $range_operator = null;
        if (in_array($operator, ['gte', '>='])) {
            $range_operator = 'gte';
        } elseif (in_array($operator, ['lte', '<='])) {
            $range_operator = 'lte';
        } elseif (in_array($operator, ['gt', '>'])) {
            $range_operator = 'gt';
        } elseif (in_array($operator, ['lt', '<'])) {
            $range_operator = 'lt';
        }
        if ($range_operator === null) {
            throw new InvalidParamException("Operator '{$operator}' is not implemented.");
        }
        $filter = ['range' => [$column => [$range_operator => $value]]];
        return $filter;
    }