NOW MANAGED ON CODEBERG
Improve efficiency of single entity search indexing
Dan Brown0651eae7ecde
diff --git a/app/Services/SearchService.php b/app/Services/SearchService.phpindex ae8dd008a..ef11de728 100644--- a/app/Services/SearchService.php+++ b/app/Services/SearchService.php@@ -100,7 +100,11 @@ class SearchService$nameTerms = $this->generateTermArrayFromText($entity->name, 5);$bodyTerms = $this->generateTermArrayFromText($entity->getText(), 1);$terms = array_merge($nameTerms, $bodyTerms);- $entity->searchTerms()->createMany($terms);+ foreach ($terms as $index => $term) {+ $terms[$index]['entity_type'] = $entity->getMorphClass();+ $terms[$index]['entity_id'] = $entity->id;+ }+ $this->searchTerm->newQuery()->insert($terms);}/**@@ -121,7 +125,7 @@ class SearchService$chunkedTerms = array_chunk($terms, 500);foreach ($chunkedTerms as $termChunk) {- $this->searchTerm->insert($termChunk);+ $this->searchTerm->newQuery()->insert($termChunk);}}