Skip to content

Commit

Permalink
changed analyzer
Browse files Browse the repository at this point in the history
  • Loading branch information
eddierusinskas committed Apr 13, 2023
1 parent 66c1ec2 commit b301a92
Showing 1 changed file with 11 additions and 10 deletions.
21 changes: 11 additions & 10 deletions src/Services/OpenSearchClient.php
Original file line number Diff line number Diff line change
Expand Up @@ -33,15 +33,15 @@ public function bulkUpdate(string $index, $models): callable|array
$data[] = [
'index' => [
'_index' => $index,
'_id' => $model['objectID'],
'_id' => $model['objectID'],
],
];
$data[] = $model;
});

return $this->client->bulk([
'index' => $index,
'body' => $data,
'body' => $data,
]);
}

Expand All @@ -51,38 +51,39 @@ public function bulkDelete(string $index, Collection $keys): callable|array
return [
'delete' => [
'_index' => $index,
'_id' => $key,
'_id' => $key,
],
];
})->toArray();

return $this->client->bulk([
'index' => $index,
'body' => $data,
'body' => $data,
]);
}

public function search(string $index, string $query, array $options = [])
{
return $this->client->search(array_merge([
'index' => $index,
'body' => [
'body' => [
'query' => [
'bool' => [
'should' => [
'should' => [
[
'query_string' => [
'query' => ! empty($query) ? "*$query*" : '*',
'analyzer' => 'keyword',
'query' => !empty($query) ? "*$query*" : '*',
'analyzer' => 'whitespace',
],
],
[
'multi_match' => [
'query' => $query,
'analyzer' => 'keyword',
'query' => $query,
'analyzer' => 'whitespace',
],
],
],
'minimum_should_match' => 1
],
],
],
Expand Down

0 comments on commit b301a92

Please sign in to comment.