Skip to content

Commit

Permalink
A few more tweaks
Browse files Browse the repository at this point in the history
  • Loading branch information
ryanmitchell committed Jan 27, 2025
1 parent 11c8b7a commit 9ab25df
Showing 1 changed file with 8 additions and 4 deletions.
12 changes: 8 additions & 4 deletions src/Typesense/Query.php
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,11 @@ private function wheresToFilter(array $wheres): string
break;

default:
$filterBy .= $where['column'].':'.($where['operator'] != '=' ? $where['operator'] : '').$this->transformValueForTypeSense($schemaType, $where['value']);
if ($where['operator'] == 'like') {
$where['value'] = str_replace(['%"', '"%'], '', $where['value']);
}

$filterBy .= $where['column'].':'.(! in_array($where['operator'], ['like']) ? $where['operator'] : '').$this->transformValueForTypeSense($schemaType, $where['value']);
break;
}

Expand All @@ -73,11 +77,11 @@ private function wheresToFilter(array $wheres): string
return $filterBy;
}

private function transformArrayOfValuesForTypeSense(string $schemaType, array $values): array
private function transformArrayOfValuesForTypeSense(string $schemaType, array $values): string
{
return json_encode(
collect($where['values'])
->map(fn ($value) => $this->transformValueForTypeSense($schemaType, $values))
collect($values)
->map(fn ($value) => ray($value) && $this->transformValueForTypeSense($schemaType, $value))
->values()
->all()
);
Expand Down

0 comments on commit 9ab25df

Please sign in to comment.