Differential D18544 Diff 44548 src/applications/search/fulltextstorage/PhabricatorElasticFulltextStorageEngine.php
Changeset View
Changeset View
Standalone View
Standalone View
src/applications/search/fulltextstorage/PhabricatorElasticFulltextStorageEngine.php
Show First 20 Lines • Show All 99 Lines • ▼ Show 20 Lines | foreach ($doc->getRelationshipData() as $field) { | ||||
if ($time) { | if ($time) { | ||||
$spec[$field_name.'_ts'] = $time; | $spec[$field_name.'_ts'] = $time; | ||||
} | } | ||||
} | } | ||||
$this->executeRequest($host, "/{$type}/{$phid}/", $spec, 'PUT'); | $this->executeRequest($host, "/{$type}/{$phid}/", $spec, 'PUT'); | ||||
} | } | ||||
public function reconstructDocument($phid) { | |||||
$type = phid_get_type($phid); | |||||
$host = $this->getHostForRead(); | |||||
$response = $this->executeRequest($host, "/{$type}/{$phid}", array()); | |||||
if (empty($response['exists'])) { | |||||
return null; | |||||
} | |||||
$hit = $response['_source']; | |||||
$doc = new PhabricatorSearchAbstractDocument(); | |||||
$doc->setPHID($phid); | |||||
$doc->setDocumentType($response['_type']); | |||||
$doc->setDocumentTitle($hit['title']); | |||||
$doc->setDocumentCreated($hit['dateCreated']); | |||||
$doc->setDocumentModified($hit[$this->getTimestampField()]); | |||||
foreach ($hit['field'] as $fdef) { | |||||
$field_type = $fdef['type']; | |||||
$doc->addField($field_type, $hit[$field_type], $fdef['aux']); | |||||
} | |||||
foreach ($hit['relationship'] as $rtype => $rships) { | |||||
foreach ($rships as $rship) { | |||||
$doc->addRelationship( | |||||
$rtype, | |||||
$rship['phid'], | |||||
$rship['phidType'], | |||||
$rship['when']); | |||||
} | |||||
} | |||||
return $doc; | |||||
} | |||||
private function buildSpec(PhabricatorSavedQuery $query) { | private function buildSpec(PhabricatorSavedQuery $query) { | ||||
$q = new PhabricatorElasticsearchQueryBuilder('bool'); | $q = new PhabricatorElasticsearchQueryBuilder('bool'); | ||||
$query_string = $query->getParameter('query'); | $query_string = $query->getParameter('query'); | ||||
if (strlen($query_string)) { | if (strlen($query_string)) { | ||||
$fields = $this->getTypeConstants('PhabricatorSearchDocumentFieldType'); | $fields = $this->getTypeConstants('PhabricatorSearchDocumentFieldType'); | ||||
// Build a simple_query_string query over all fields that must match all | // Build a simple_query_string query over all fields that must match all | ||||
// of the words in the search string. | // of the words in the search string. | ||||
▲ Show 20 Lines • Show All 428 Lines • Show Last 20 Lines |