From bdc2ff9ffd8236a3a01cf2300b19f76ab9332691 Mon Sep 17 00:00:00 2001 From: Alec Ritson Date: Tue, 17 Dec 2024 13:07:48 +0000 Subject: [PATCH] Fix pagination --- src/Engines/TypesenseEngine.php | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/Engines/TypesenseEngine.php b/src/Engines/TypesenseEngine.php index e7631d7..8481841 100644 --- a/src/Engines/TypesenseEngine.php +++ b/src/Engines/TypesenseEngine.php @@ -30,7 +30,7 @@ public function get(): SearchResults $response = $engine->getMultiSearch()->perform($request, [ 'collection' => (new $this->modelType)->searchableAs(), ]); - + $completeResults = $response['results'][0]; unset( $response['results'][0]); @@ -190,11 +190,16 @@ protected function buildSearch(array $options): array 'q' => $searchQuery->query, 'facet_query' => $facetQuery, 'prefix' => false, + 'exlude_fields' => 'embedding', 'max_facet_values' => 50, 'sort_by' => $this->sortRaw ?: ($this->sortByIsValid() ? $this->sort : '_text_match:desc'), 'facet_by' => implode(',', $searchQuery->facets), ]; + if ($this->query) { + $params['vector_query'] = "embedding:([], k: 200)"; + } + if ($filters->count()) { $params['filter_by'] = $filters->join(' && '); }