3 final class PhabricatorNgramsIndexEngineExtension
4 extends PhabricatorIndexEngineExtension
{
6 const EXTENSIONKEY
= 'ngrams';
8 public function getExtensionName() {
9 return pht('Ngrams Engine');
12 public function getIndexVersion($object) {
13 $ngrams = $object->newNgrams();
14 $map = mpull($ngrams, 'getValue', 'getNgramKey');
16 $serialized = serialize($map);
18 return PhabricatorHash
::digestForIndex($serialized);
21 public function shouldIndexObject($object) {
22 return ($object instanceof PhabricatorNgramsInterface
);
25 public function indexObject(
26 PhabricatorIndexEngine
$engine,
29 foreach ($object->newNgrams() as $ngram) {
30 $ngram->writeNgram($object->getID());