Skip to content

Commit

Permalink
Support like query (issue yiisoft#37)
Browse files Browse the repository at this point in the history
  • Loading branch information
E.Igonichkina committed Jun 6, 2017
1 parent b5d1612 commit 1e4f366
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion QueryBuilder.php
Original file line number Diff line number Diff line change
Expand Up @@ -416,6 +416,14 @@ protected function buildCompositeInCondition($operator, $columns, $values)

private function buildLikeCondition($operator, $operands)
{
throw new NotSupportedException('like conditions are not supported by elasticsearch.');
if (!isset($operands[0], $operands[1])) {
throw new InvalidParamException("Operator '$operator' requires two operands.");
}

if( $operator == 'like') {
$like_text = '*' . $operands[1] . '*';
$query = ['wildcard' => [$operands[0] => $like_text]];
}
return $query;
}
}

0 comments on commit 1e4f366

Please sign in to comment.