Differential D18500 Diff 44446 src/applications/search/engineextension/PhabricatorFerretFulltextEngineExtension.php
Changeset View
Changeset View
Standalone View
Standalone View
src/applications/search/engineextension/PhabricatorFerretFulltextEngineExtension.php
| Show First 20 Lines • Show All 44 Lines • ▼ Show 20 Lines | public function indexFulltextObject( | ||||
| ); | ); | ||||
| foreach ($document->getFieldData() as $field) { | foreach ($document->getFieldData() as $field) { | ||||
| list($key, $raw_corpus) = $field; | list($key, $raw_corpus) = $field; | ||||
| if (!strlen($raw_corpus)) { | if (!strlen($raw_corpus)) { | ||||
| continue; | continue; | ||||
| } | } | ||||
| $normal_corpus = $stemmer->stemCorpus($raw_corpus); | |||||
| $term_corpus = $ngram_engine->newTermsCorpus($raw_corpus); | $term_corpus = $ngram_engine->newTermsCorpus($raw_corpus); | ||||
| $normal_corpus = $stemmer->stemCorpus($raw_corpus); | |||||
| $normal_coprus = $ngram_engine->newTermsCorpus($normal_corpus); | |||||
| if (!isset($ferret_corpus_map[$key])) { | if (!isset($ferret_corpus_map[$key])) { | ||||
| $ferret_corpus_map[$key] = $empty_template; | $ferret_corpus_map[$key] = $empty_template; | ||||
| } | } | ||||
| $ferret_corpus_map[$key]['raw'][] = $raw_corpus; | $ferret_corpus_map[$key]['raw'][] = $raw_corpus; | ||||
| $ferret_corpus_map[$key]['term'][] = $term_corpus; | $ferret_corpus_map[$key]['term'][] = $term_corpus; | ||||
| $ferret_corpus_map[$key]['normal'][] = $normal_corpus; | $ferret_corpus_map[$key]['normal'][] = $normal_corpus; | ||||
| $ferret_corpus_map[$key_all]['raw'][] = $raw_corpus; | $ferret_corpus_map[$key_all]['raw'][] = $raw_corpus; | ||||
| $ferret_corpus_map[$key_all]['term'][] = $term_corpus; | $ferret_corpus_map[$key_all]['term'][] = $term_corpus; | ||||
| $ferret_corpus_map[$key_all]['normal'][] = $normal_corpus; | $ferret_corpus_map[$key_all]['normal'][] = $normal_corpus; | ||||
| } | } | ||||
| $ferret_fields = array(); | $ferret_fields = array(); | ||||
| $ngrams_source = array(); | |||||
| foreach ($ferret_corpus_map as $key => $fields) { | foreach ($ferret_corpus_map as $key => $fields) { | ||||
| $raw_corpus = $fields['raw']; | $raw_corpus = $fields['raw']; | ||||
| $raw_corpus = implode("\n", $raw_corpus); | $raw_corpus = implode("\n", $raw_corpus); | ||||
| $ngrams_source[] = $raw_corpus; | |||||
| $normal_corpus = $fields['normal']; | $normal_corpus = $fields['normal']; | ||||
| $normal_corpus = implode("\n", $normal_corpus); | $normal_corpus = implode(' ', $normal_corpus); | ||||
| if (strlen($normal_corpus)) { | |||||
| $ngrams_source[] = $normal_corpus; | |||||
| $normal_corpus = ' '.$normal_corpus.' '; | |||||
| } | |||||
| $term_corpus = $fields['term']; | $term_corpus = $fields['term']; | ||||
| $term_corpus = implode(' ', $term_corpus); | $term_corpus = implode(' ', $term_corpus); | ||||
| if (strlen($term_corpus)) { | if (strlen($term_corpus)) { | ||||
| $ngrams_source[] = $term_corpus; | |||||
| $term_corpus = ' '.$term_corpus.' '; | $term_corpus = ' '.$term_corpus.' '; | ||||
| } | } | ||||
| $ferret_fields[] = $engine->newFieldObject() | $ferret_fields[] = $engine->newFieldObject() | ||||
| ->setFieldKey($key) | ->setFieldKey($key) | ||||
| ->setRawCorpus($raw_corpus) | ->setRawCorpus($raw_corpus) | ||||
| ->setTermCorpus($term_corpus) | ->setTermCorpus($term_corpus) | ||||
| ->setNormalCorpus($normal_corpus); | ->setNormalCorpus($normal_corpus); | ||||
| } | } | ||||
| $ngrams_source = implode(' ', $ngrams_source); | |||||
| $ngrams_source = $ferret_corpus_map[$key_all]['raw']; | |||||
| $ngrams_source = implode("\n", $ngrams_source); | |||||
| $ngrams = $ngram_engine->getNgramsFromString($ngrams_source, 'index'); | $ngrams = $ngram_engine->getNgramsFromString($ngrams_source, 'index'); | ||||
| $ferret_document->openTransaction(); | $ferret_document->openTransaction(); | ||||
| try { | try { | ||||
| $this->deleteOldDocument($engine, $object, $document); | $this->deleteOldDocument($engine, $object, $document); | ||||
| ▲ Show 20 Lines • Show All 72 Lines • Show Last 20 Lines | |||||