]>
BookStack Code Mirror - bookstack/commitdiff
projects
/
bookstack
/ commitdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
| commitdiff |
tree
raw
|
inline
| side by side (parent:
1552417
)
Improve efficiency of single entity search indexing
author
Dan Brown
<redacted>
Sun, 26 Mar 2017 18:34:53 +0000
(19:34 +0100)
committer
Dan Brown
<redacted>
Sun, 26 Mar 2017 18:34:53 +0000
(19:34 +0100)
app/Services/SearchService.php
patch
|
blob
|
history
diff --git
a/app/Services/SearchService.php
b/app/Services/SearchService.php
index ae8dd008a86ef81b220b580c59288750414494dd..ef11de72864f579c3baa25291f2a41e1c666517a 100644
(file)
--- 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);
$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) {
$chunkedTerms = array_chunk($terms, 500);
foreach ($chunkedTerms as $termChunk) {
- $this->searchTerm->insert($termChunk);
+ $this->searchTerm->
newQuery()->
insert($termChunk);
}
}
}
}