From d67cc8e5c59c435bca027ac3e5f377aeab23412d Mon Sep 17 00:00:00 2001 From: epriestley Date: Fri, 8 Sep 2017 08:13:08 -0700 Subject: [PATCH] Remove some redundant information from the Ferret engine index Summary: Ref T12819. The "full" field has all other fields, and the "core" field has "title" and "body". Due to the way the "full" and "core" fields were being built, the "core" field also got included in the "full" field, so the "full" field has two copies of the title, two copies of the body, and then one copy of everything else. Put only one copy of each distinct thing in each "full" and "core". Also, simplify the logic a little bit so we build these virtual fields in a more consistent way. Test Plan: Ran `bin/search index` and looked at the fields in the database, saw less redundant information. Reviewers: chad Reviewed By: chad Maniphest Tasks: T12819 Differential Revision: https://secure.phabricator.com/D18580 --- .../PhabricatorFerretFulltextEngineExtension.php | 15 ++++++--------- 1 file changed, 6 insertions(+), 9 deletions(-) diff --git a/src/applications/search/engineextension/PhabricatorFerretFulltextEngineExtension.php b/src/applications/search/engineextension/PhabricatorFerretFulltextEngineExtension.php index 4344fe1623..6903072345 100644 --- a/src/applications/search/engineextension/PhabricatorFerretFulltextEngineExtension.php +++ b/src/applications/search/engineextension/PhabricatorFerretFulltextEngineExtension.php @@ -66,9 +66,12 @@ final class PhabricatorFerretFulltextEngineExtension ); break; } - } - $key_all = PhabricatorSearchDocumentFieldType::FIELD_ALL; + $virtual_fields[] = array( + PhabricatorSearchDocumentFieldType::FIELD_ALL, + $raw_corpus, + ); + } $empty_template = array( 'raw' => array(), @@ -76,9 +79,7 @@ final class PhabricatorFerretFulltextEngineExtension 'normal' => array(), ); - $ferret_corpus_map = array( - $key_all => $empty_template, - ); + $ferret_corpus_map = array(); foreach ($virtual_fields as $field) { list($key, $raw_corpus) = $field; @@ -98,10 +99,6 @@ final class PhabricatorFerretFulltextEngineExtension $ferret_corpus_map[$key]['raw'][] = $raw_corpus; $ferret_corpus_map[$key]['term'][] = $term_corpus; $ferret_corpus_map[$key]['normal'][] = $normal_corpus; - - $ferret_corpus_map[$key_all]['raw'][] = $raw_corpus; - $ferret_corpus_map[$key_all]['term'][] = $term_corpus; - $ferret_corpus_map[$key_all]['normal'][] = $normal_corpus; } $ferret_fields = array();