Page Menu
Home
Phabricator
Search
Configure Global Search
Log In
Files
F13959449
D18647.id44766.diff
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Award Token
Flag For Later
Size
1 KB
Referenced Files
None
Subscribers
None
D18647.id44766.diff
View Options
diff --git a/src/applications/search/ferret/PhabricatorFerretEngine.php b/src/applications/search/ferret/PhabricatorFerretEngine.php
--- a/src/applications/search/ferret/PhabricatorFerretEngine.php
+++ b/src/applications/search/ferret/PhabricatorFerretEngine.php
@@ -88,16 +88,23 @@
}
private function getNgramsFromString($value, $as_term) {
+ $value = phutil_utf8_strtolower($value);
$tokens = $this->tokenizeString($value);
- $ngrams = array();
+ // First, extract unique tokens from the string. This reduces the number
+ // of `phutil_utf8v()` calls we need to make if we are indexing a large
+ // corpus with redundant terms.
+ $unique_tokens = array();
foreach ($tokens as $token) {
- $token = phutil_utf8_strtolower($token);
-
if ($as_term) {
$token = ' '.$token.' ';
}
+ $unique_tokens[$token] = true;
+ }
+
+ $ngrams = array();
+ foreach ($unique_tokens as $token => $ignored) {
$token_v = phutil_utf8v($token);
$len = (count($token_v) - 2);
for ($ii = 0; $ii < $len; $ii++) {
File Metadata
Details
Attached
Mime Type
text/plain
Expires
Oct 15 2024, 7:28 PM (4 w, 4 d ago)
Storage Engine
blob
Storage Format
Encrypted (AES-256-CBC)
Storage Handle
6714073
Default Alt Text
D18647.id44766.diff (1 KB)
Attached To
Mode
D18647: Improve Ferret engine indexing performance for large blocks of text
Attached
Detach File
Event Timeline
Log In to Comment