From c662dda0f17d886fb864ecfde0e8b37b4fe090f8 Mon Sep 17 00:00:00 2001 From: epriestley Date: Fri, 8 Sep 2017 09:03:32 -0700 Subject: [PATCH] When selecting Ferret ngrams, select term ngrams (not raw ngrams) for term search Summary: Ref T12819. For queries like `v0.2`, we would incorrectly search for ngrams including `0.2`, but this is only a substring ngram: the term corpus splits this into `v0` and `2`, so `0.2` is not in the ngrams table. When executing term queries, search for term ngrams instead. This makes "v0.2" work properly again. Test Plan: Searched for "v0.2", found a task with "v0.2" in the title. Reviewers: chad Reviewed By: chad Maniphest Tasks: T12819 Differential Revision: https://secure.phabricator.com/D18581 --- .../query/policy/PhabricatorCursorPagedPolicyAwareQuery.php | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/infrastructure/query/policy/PhabricatorCursorPagedPolicyAwareQuery.php b/src/infrastructure/query/policy/PhabricatorCursorPagedPolicyAwareQuery.php index 18e860ebb9..0488ba6133 100644 --- a/src/infrastructure/query/policy/PhabricatorCursorPagedPolicyAwareQuery.php +++ b/src/infrastructure/query/policy/PhabricatorCursorPagedPolicyAwareQuery.php @@ -1666,12 +1666,13 @@ abstract class PhabricatorCursorPagedPolicyAwareQuery if ($is_substring) { $ngrams = $engine->getSubstringNgramsFromString($value); } else { - $ngrams = $engine->getTermNgramsFromString($value); + $terms_value = $engine->newTermsCorpus($value); + $ngrams = $engine->getTermNgramsFromString($terms_value); // If this is a stemmed term, only look for ngrams present in both the // unstemmed and stemmed variations. if ($is_stemmed) { - $stem_value = $stemmer->stemToken($value); + $stem_value = $stemmer->stemToken($terms_value); $stem_ngrams = $engine->getTermNgramsFromString($stem_value); $ngrams = array_intersect($ngrams, $stem_ngrams); }