Skip to content

Commit

Permalink
Rename methods and parameters
Browse files Browse the repository at this point in the history
  • Loading branch information
karakhanyans committed Nov 10, 2023
1 parent a4d05ed commit 47727a8
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 12 deletions.
6 changes: 3 additions & 3 deletions config/scout.php
Original file line number Diff line number Diff line change
Expand Up @@ -174,9 +174,9 @@
'num_retries' => env('TYPESENSE_NUM_RETRIES', 3),
'retry_interval_seconds' => env('TYPESENSE_RETRY_INTERVAL_SECONDS', 1),
],
'collection-settings' => [
'model-settings' => [
// User::class => [
// 'schema' => [
// 'collection-schema' => [
// 'fields' => [
// [
// 'name' => 'id',
Expand All @@ -193,7 +193,7 @@
// ],
// 'default_sorting_field' => 'created_at',
// ],
// 'search-options' => [
// 'search-parameters' => [
// 'query_by' => [
// 'name',
// ],
Expand Down
18 changes: 9 additions & 9 deletions src/Engines/TypesenseEngine.php
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ class TypesenseEngine extends Engine
*
* @var array
*/
protected array $searchOptions = [];
protected array $searchParameters = [];

/**
* Create new Typesense engine instance.
Expand Down Expand Up @@ -231,7 +231,7 @@ public function buildSearchParameters(Builder $builder, int $page, int|null $per
{
$params = [
'q' => $builder->query,
'query_by' => implode(',', config('scout.typesense.collection-settings.'.get_class($builder->model).'.search-options.query_by')) ?? '',
'query_by' => implode(',', config('scout.typesense.model-settings.'.get_class($builder->model).'.search-parameters.query_by')) ?? '',
'filter_by' => $this->filters($builder),
'per_page' => $perPage,
'page' => $page,
Expand All @@ -246,11 +246,11 @@ public function buildSearchParameters(Builder $builder, int $page, int|null $per
'highlight_affix_num_tokens' => 4,
];

if (! empty($this->searchOptions)) {
$params = array_merge($params, $this->searchOptions);
if (! empty($this->searchParameters)) {
$params = array_merge($params, $this->searchParameters);

if ($this->searchOptions['query_by']) {
$params['query_by'] = implode(',', $this->searchOptions['query_by']);
if ($this->searchParameters['query_by']) {
$params['query_by'] = implode(',', $this->searchParameters['query_by']);
}
}

Expand Down Expand Up @@ -484,9 +484,9 @@ public function deleteIndex($name)
* @param array $options
* @return $this
*/
public function setSearchOptions(array $options): static
public function setSearchParameters(array $options): static
{
$this->searchOptions = $options;
$this->searchParameters = $options;

return $this;
}
Expand All @@ -509,7 +509,7 @@ protected function getOrCreateCollectionFromModel($model): TypesenseCollection

return $index;
} catch (ObjectNotFound $exception) {
$schema = config('scout.typesense.collection-settings.'.get_class($model).'.schema') ?? [];
$schema = config('scout.typesense.model-settings.'.get_class($model).'.collection-schema') ?? [];

if (! isset($schema['name'])) {
$schema['name'] = $model->searchableAs();
Expand Down

0 comments on commit 47727a8

Please sign in to comment.