diff --git a/src/applications/project/customfield/PhabricatorProjectDescriptionField.php b/src/applications/project/customfield/PhabricatorProjectDescriptionField.php index aaeeaeceb5..1da7ce1305 100644 --- a/src/applications/project/customfield/PhabricatorProjectDescriptionField.php +++ b/src/applications/project/customfield/PhabricatorProjectDescriptionField.php @@ -11,6 +11,7 @@ final class PhabricatorProjectDescriptionField '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 index d20734ed27..ff430e4290 100644 --- a/src/docs/user/configuration/custom_fields.diviner +++ b/src/docs/user/configuration/custom_fields.diviner @@ -102,6 +102,9 @@ When defining custom fields using a configuration option like 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 index d7ff2a3585..15b83928e1 100644 --- a/src/infrastructure/customfield/field/PhabricatorCustomFieldList.php +++ b/src/infrastructure/customfield/field/PhabricatorCustomFieldList.php @@ -339,8 +339,6 @@ final class PhabricatorCustomFieldList extends Phobject { } $field->updateAbstractDocument($document); } - - return $document; } diff --git a/src/infrastructure/customfield/standard/PhabricatorStandardCustomField.php b/src/infrastructure/customfield/standard/PhabricatorStandardCustomField.php index c2750b89a3..8400500d92 100644 --- a/src/infrastructure/customfield/standard/PhabricatorStandardCustomField.php +++ b/src/infrastructure/customfield/standard/PhabricatorStandardCustomField.php @@ -402,4 +402,25 @@ abstract class PhabricatorStandardCustomField 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); + } + } + }