From 47727a81e2943e202ca862dd2389cbfc508ea452 Mon Sep 17 00:00:00 2001 From: karakhanyans Date: Fri, 10 Nov 2023 10:10:56 +0400 Subject: [PATCH] Rename methods and parameters --- config/scout.php | 6 +++--- src/Engines/TypesenseEngine.php | 18 +++++++++--------- 2 files changed, 12 insertions(+), 12 deletions(-) diff --git a/config/scout.php b/config/scout.php index 0798a0d8..0fb0b316 100644 --- a/config/scout.php +++ b/config/scout.php @@ -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', @@ -193,7 +193,7 @@ // ], // 'default_sorting_field' => 'created_at', // ], - // 'search-options' => [ + // 'search-parameters' => [ // 'query_by' => [ // 'name', // ], diff --git a/src/Engines/TypesenseEngine.php b/src/Engines/TypesenseEngine.php index 12282789..f3fde380 100644 --- a/src/Engines/TypesenseEngine.php +++ b/src/Engines/TypesenseEngine.php @@ -29,7 +29,7 @@ class TypesenseEngine extends Engine * * @var array */ - protected array $searchOptions = []; + protected array $searchParameters = []; /** * Create new Typesense engine instance. @@ -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, @@ -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']); } } @@ -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; } @@ -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();