Skip to content

Commit 7cb148a

Browse files
authored
Use multisearch end point for search operations (#15)
2 parents ceebe93 + 2bd0de0 commit 7cb148a

File tree

2 files changed

+16
-3
lines changed

2 files changed

+16
-3
lines changed

config/statamic-typesense.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,8 @@
22

33
return [
44

5-
// if you make this higher it will use more memory
6-
// but be quicker to update large numbers of documents
5+
// If you make this higher it will use more memory
6+
// but be quicker to update large numbers of documents.
77
'insert_chunk_size' => 100,
88

99
];

src/Typesense/Index.php

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -111,7 +111,20 @@ public function searchUsingApi($query, array $options = []): array
111111
->join(',') ?: '*';
112112
}
113113

114-
$searchResults = $this->getOrCreateIndex()->documents->search($options);
114+
$this->getOrCreateIndex();
115+
116+
// Using POST multiSearch to avoid potential request size limitations
117+
// (regular search uses GET and is limited in size by Typesense)
118+
$searchRequest = [
119+
'searches' => [
120+
array_merge($options, [
121+
'collection' => $this->name,
122+
]),
123+
],
124+
];
125+
126+
$searchResults = $this->client->multiSearch->perform($searchRequest, []);
127+
$searchResults = array_shift($searchResults['results']);
115128

116129
$total = count($searchResults['hits']);
117130

0 commit comments

Comments
 (0)