Page Menu
Home
Phabricator
Search
Configure Global Search
Log In
Files
F15341268
D18710.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
D18710.diff
View Options
diff --git a/src/applications/search/management/PhabricatorSearchManagementNgramsWorkflow.php b/src/applications/search/management/PhabricatorSearchManagementNgramsWorkflow.php
--- a/src/applications/search/management/PhabricatorSearchManagementNgramsWorkflow.php
+++ b/src/applications/search/management/PhabricatorSearchManagementNgramsWorkflow.php
@@ -16,19 +16,49 @@
'name' => 'reset',
'help' => pht('Reset all common ngram records.'),
),
+ array(
+ 'name' => 'threshold',
+ 'param' => 'threshold',
+ 'help' => pht(
+ 'Prune ngrams present in more than this fraction of '.
+ 'documents.'),
+ ),
));
}
public function execute(PhutilArgumentParser $args) {
+ $min_documents = 4096;
+
$is_reset = $args->getArg('reset');
+ $threshold = $args->getArg('threshold');
+
+ if ($is_reset && $threshold !== null) {
+ throw new PhutilArgumentUsageException(
+ pht('Specify either --reset or --threshold, not both.'));
+ }
+
+ if (!$is_reset && $threshold === null) {
+ throw new PhutilArgumentUsageException(
+ pht('Specify either --reset or --threshold.'));
+ }
+
+ if (!$is_reset) {
+ if (!is_numeric($threshold)) {
+ throw new PhutilArgumentUsageException(
+ pht('Specify a numeric threshold between 0 and 1.'));
+ }
+
+ $threshold = (double)$threshold;
+ if ($threshold <= 0 || $threshold >= 1) {
+ throw new PhutilArgumentUsageException(
+ pht('Threshold must be greater than 0.0 and less than 1.0.'));
+ }
+ }
$all_objects = id(new PhutilClassMapQuery())
->setAncestorClass('PhabricatorFerretInterface')
->execute();
- $min_documents = 4096;
- $threshold = 0.15;
-
foreach ($all_objects as $object) {
$engine = $object->newFerretEngine();
$conn = $object->establishConnection('w');
File Metadata
Details
Attached
Mime Type
text/plain
Expires
Mon, Mar 10, 7:31 PM (1 w, 3 d ago)
Storage Engine
blob
Storage Format
Encrypted (AES-256-CBC)
Storage Handle
7351975
Default Alt Text
D18710.diff (1 KB)
Attached To
Mode
D18710: Parameterize the common ngrams threshold
Attached
Detach File
Event Timeline
Log In to Comment