Skip to content

Commit 14ebad0

Browse files
Change Typesense action mode to emplace when import documents (#936)
This PR changes the action mode to emplace when importing documents to Typesense. This is useful to make sure data will not be overwritten when user have other fields in Typesense that is managed seperately (like externally generated embeddings). Related documentation: https://typesense.org/docs/29.0/api/documents.html#action-modes-create-upsert-update-emplace
1 parent e0be30e commit 14ebad0

File tree

2 files changed

+2
-2
lines changed

2 files changed

+2
-2
lines changed

src/Engines/TypesenseEngine.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -111,7 +111,7 @@ public function update($models)
111111
* @throws \Typesense\Exceptions\TypesenseClientError
112112
* @throws \Http\Client\Exception
113113
*/
114-
protected function importDocuments(TypesenseCollection $collectionIndex, array $documents, string $action = 'upsert'): Collection
114+
protected function importDocuments(TypesenseCollection $collectionIndex, array $documents, string $action = 'emplace'): Collection
115115
{
116116
$importedDocuments = $collectionIndex->getDocuments()->import($documents, ['action' => $action]);
117117

tests/Unit/TypesenseEngineTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -133,7 +133,7 @@ public function test_update_method(): void
133133
$documents->expects($this->once())
134134
->method('import')
135135
->with(
136-
[['id' => 1, 'name' => 'Model 1']], ['action' => 'upsert'],
136+
[['id' => 1, 'name' => 'Model 1']], ['action' => 'emplace'],
137137
)
138138
->willReturn([[
139139
'success' => true,

0 commit comments

Comments
 (0)