@recaptime-dev's working patches + fork for Phorge, a community fork of Phabricator. (Upstream dev and stable branches are at upstream/main and upstream/stable respectively.) hq.recaptime.dev/wiki/Phorge
phorge phabricator
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

Create a virtual "core" field in the Ferret engine for "title and body together"

Summary: See PHI46. The `core:` function means "find results in either the title or body, but not other auxiliary fields like comments".

Test Plan: Searched for text present in the title (yes), body (yes), and comments (no) with the `core:...` prefix.

Reviewers: chad

Reviewed By: chad

Differential Revision: https://secure.phabricator.com/D18514

+23 -1
+1
src/applications/search/constants/PhabricatorSearchDocumentFieldType.php
··· 6 6 const FIELD_BODY = 'body'; 7 7 const FIELD_COMMENT = 'cmnt'; 8 8 const FIELD_ALL = 'full'; 9 + const FIELD_CORE = 'core'; 9 10 10 11 }
+20 -1
src/applications/search/engineextension/PhabricatorFerretFulltextEngineExtension.php
··· 32 32 $stemmer = new PhutilSearchStemmer(); 33 33 $ngram_engine = id(new PhabricatorNgramEngine()); 34 34 35 + // Copy all of the "title" and "body" fields to create new "core" fields. 36 + // This allows users to search "in title or body" with the "core:" prefix. 37 + $document_fields = $document->getFieldData(); 38 + $virtual_fields = array(); 39 + foreach ($document_fields as $field) { 40 + $virtual_fields[] = $field; 41 + 42 + list($key, $raw_corpus) = $field; 43 + switch ($key) { 44 + case PhabricatorSearchDocumentFieldType::FIELD_TITLE: 45 + case PhabricatorSearchDocumentFieldType::FIELD_BODY: 46 + $virtual_fields[] = array( 47 + PhabricatorSearchDocumentFieldType::FIELD_CORE, 48 + $raw_corpus, 49 + ); 50 + break; 51 + } 52 + } 53 + 35 54 $key_all = PhabricatorSearchDocumentFieldType::FIELD_ALL; 36 55 37 56 $empty_template = array( ··· 44 63 $key_all => $empty_template, 45 64 ); 46 65 47 - foreach ($document->getFieldData() as $field) { 66 + foreach ($virtual_fields as $field) { 48 67 list($key, $raw_corpus) = $field; 49 68 if (!strlen($raw_corpus)) { 50 69 continue;
+2
src/infrastructure/query/policy/PhabricatorCursorPagedPolicyAwareQuery.php
··· 1406 1406 $function_map = array( 1407 1407 'all' => PhabricatorSearchDocumentFieldType::FIELD_ALL, 1408 1408 'title' => PhabricatorSearchDocumentFieldType::FIELD_TITLE, 1409 + 'body' => PhabricatorSearchDocumentFieldType::FIELD_BODY, 1410 + 'core' => PhabricatorSearchDocumentFieldType::FIELD_CORE, 1409 1411 ); 1410 1412 1411 1413 $current_function = 'all';