diff --git a/src/applications/project/customfield/PhabricatorProjectDescriptionField.php b/src/applications/project/customfield/PhabricatorProjectDescriptionField.php --- a/src/applications/project/customfield/PhabricatorProjectDescriptionField.php +++ b/src/applications/project/customfield/PhabricatorProjectDescriptionField.php @@ -11,6 +11,7 @@ 'name' => pht('Description'), 'type' => 'remarkup', 'description' => pht('Short project description.'), + 'fulltext' => PhabricatorSearchField::FIELD_BODY, ), )); } diff --git a/src/docs/user/configuration/custom_fields.diviner b/src/docs/user/configuration/custom_fields.diviner --- a/src/docs/user/configuration/custom_fields.diviner +++ b/src/docs/user/configuration/custom_fields.diviner @@ -102,6 +102,9 @@ defaults to `true`). (Note: Empty fields are not shown.) - **search**: Show this field on the application's search interface, allowing users to filter objects by the field value. + - **fulltext**: Index the text in this field as part of the object's global + full-text index. This allows users to find the object by searching for + the field's contents using global search. - **caption**: A caption to display underneath the field (optional). - **required**: True if the user should be required to provide a value. - **options**: If type is set to **select**, provide options for the dropdown diff --git a/src/infrastructure/customfield/field/PhabricatorCustomFieldList.php b/src/infrastructure/customfield/field/PhabricatorCustomFieldList.php --- a/src/infrastructure/customfield/field/PhabricatorCustomFieldList.php +++ b/src/infrastructure/customfield/field/PhabricatorCustomFieldList.php @@ -339,8 +339,6 @@ } $field->updateAbstractDocument($document); } - - return $document; } diff --git a/src/infrastructure/customfield/standard/PhabricatorStandardCustomField.php b/src/infrastructure/customfield/standard/PhabricatorStandardCustomField.php --- a/src/infrastructure/customfield/standard/PhabricatorStandardCustomField.php +++ b/src/infrastructure/customfield/standard/PhabricatorStandardCustomField.php @@ -402,4 +402,25 @@ return 'std:control:'.$key; } + public function shouldAppearInGlobalSearch() { + return $this->getFieldConfigValue('fulltext', false); + } + + public function updateAbstractDocument( + PhabricatorSearchAbstractDocument $document) { + + $field_key = $this->getFieldConfigValue('fulltext'); + + // If the caller or configuration didn't specify a valid field key, + // generate one automatically from the field index. + if (!is_string($field_key) || (strlen($field_key) != 4)) { + $field_key = '!'.substr($this->getFieldIndex(), 0, 3); + } + + $field_value = $this->getFieldValue(); + if (strlen($field_value)) { + $document->addField($field_key, $field_value); + } + } + }