+
+ /**
+ * For the given entity, Generate an array of term data details.
+ * Is the raw term data, not instances of SearchTerm models.
+ *
+ * @returns array{term: string, score: float}[]
+ */
+ protected function entityToTermDataArray(Entity $entity): array
+ {
+ $nameTerms = $this->generateTermArrayFromText($entity->name, 40 * $entity->searchFactor);
+ $bodyTerms = $this->generateTermArrayFromText($entity->getText(), 1 * $entity->searchFactor);
+ $termData = array_merge($nameTerms, $bodyTerms);
+
+ foreach ($termData as $index => $term) {
+ $termData[$index]['entity_type'] = $entity->getMorphClass();
+ $termData[$index]['entity_id'] = $entity->id;
+ }
+
+ return $termData;
+ }