1
0
Fork 0
mirror of https://we.phorge.it/source/phorge.git synced 2024-12-23 22:10:55 +01:00

Allow standard custom fields to be indexed in global fulltext search

Summary: Fixes T6399. This allows you to use global search to find projects by searching for text in their descriptions.

Test Plan: Added a unique word to a project description, reindexed it, searched, got a hit.

Reviewers: btrahan

Reviewed By: btrahan

Subscribers: epriestley

Maniphest Tasks: T6399

Differential Revision: https://secure.phabricator.com/D10748
This commit is contained in:
epriestley 2014-10-27 13:37:41 -07:00
parent 6410d8fd16
commit de40bc0c1d
4 changed files with 25 additions and 2 deletions

View file

@ -11,6 +11,7 @@ final class PhabricatorProjectDescriptionField
'name' => pht('Description'),
'type' => 'remarkup',
'description' => pht('Short project description.'),
'fulltext' => PhabricatorSearchField::FIELD_BODY,
),
));
}

View file

@ -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

View file

@ -339,8 +339,6 @@ final class PhabricatorCustomFieldList extends Phobject {
}
$field->updateAbstractDocument($document);
}
return $document;
}

View file

@ -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);
}
}
}