public function executeSearch(PhabricatorSearchQuery $query) { $spec = array(); $filter = array(); if ($query->getQuery()) { $spec[] = array('field' => array('field.corpus' => $query->getQuery())); } $exclude = $query->getParameter('exclude'); if ($exclude) { $filter[] = array('not' => array('ids' => array('values' => array($exclude)))); } $type = $query->getParameter('type'); if ($type) { $uri = "/phabricator/{$type}/_search"; } else { // Don't use '/phabricator/_search' for the case that there is something // else in the index (for example if 'phabricator' is only an alias to // some bigger index). $types = PhabricatorSearchAbstractDocument::getSupportedTypes(); $uri = '/phabricator/' . implode(',', array_keys($types)) . '/_search'; } $rel_mapping = array('author' => PhabricatorSearchRelationship::RELATIONSHIP_AUTHOR, 'open' => PhabricatorSearchRelationship::RELATIONSHIP_OPEN, 'owner' => PhabricatorSearchRelationship::RELATIONSHIP_OWNER, 'project' => PhabricatorSearchRelationship::RELATIONSHIP_PROJECT, 'repository' => PhabricatorSearchRelationship::RELATIONSHIP_REPOSITORY); foreach ($rel_mapping as $name => $field) { $param = $query->getParameter($name); if (is_array($param)) { $should = array(); foreach ($param as $val) { $should[] = array('text' => array("relationship.{$field}.phid" => array('query' => $val, 'type' => 'phrase'))); } // We couldn't solve it by minimum_number_should_match because it can // match multiple owners without matching author. $spec[] = array('bool' => array('should' => $should)); } else { if ($param) { $filter[] = array('exists' => array('field' => "relationship.{$field}.phid")); } } } if ($spec) { $spec = array('query' => array('bool' => array('must' => $spec))); } if ($filter) { $filter = array('filter' => array('and' => $filter)); if ($spec) { $spec = array('query' => array('filtered' => $spec + $filter)); } else { $spec = $filter; } } $spec['from'] = (int) $query->getParameter('offset', 0); $spec['size'] = (int) $query->getParameter('limit', 25); $response = $this->executeRequest($uri, $spec); $phids = ipull($response['hits']['hits'], '_id'); return $phids; }
public function processRequest() { $request = $this->getRequest(); $user = $request->getUser(); $query = new PhabricatorSearchQuery(); $query_str = $request->getStr('query'); $matches = array(); $query->setQuery($query_str); $query->setParameter('type', $this->type); switch ($request->getStr('filter')) { case 'assigned': $query->setParameter('owner', array($user->getPHID())); $query->setParameter('open', 1); break; case 'created': $query->setParameter('author', array($user->getPHID())); $query->setParameter('open', 1); break; case 'open': $query->setParameter('open', 1); break; } $engine = PhabricatorSearchEngineSelector::newSelector()->newEngine(); $results = $engine->executeSearch($query); $phids = array_fill_keys(ipull($results, 'phid'), true); $phids += $this->queryObjectNames($query_str); $phids = array_keys($phids); $handles = id(new PhabricatorObjectHandleData($phids))->loadHandles(); $data = array(); foreach ($handles as $handle) { $view = new PhabricatorHandleObjectSelectorDataView($handle); $data[] = $view->renderData(); } return id(new AphrontAjaxResponse())->setContent($data); }
private function buildJumpResponse($nav) { $request = $this->getRequest(); $jump = $request->getStr('jump'); $response = PhabricatorJumpNavHandler::jumpPostResponse($jump); if ($response) { return $response; } else { if ($request->isFormPost()) { $query = new PhabricatorSearchQuery(); $query->setQuery($jump); $query->save(); return id(new AphrontRedirectResponse())->setURI('/search/' . $query->getQueryKey() . '/'); } } $nav->appendChild($this->buildJumpPanel($jump)); return $this->buildStandardPageResponse($nav, array('title' => 'Jump Nav')); }
public function processRequest() { $request = $this->getRequest(); if ($this->username) { $user = id(new PhabricatorUser())->loadOneWhere('username = %s', $this->username); } else { $user = $request->getUser(); } $content = array(); if (!$user) { $error_view = new AphrontErrorView(); $error_view->setSeverity(AphrontErrorView::SEVERITY_ERROR); $error_body = 'User name ' . '<b>' . phutil_escape_html($this->username) . '</b>' . ' doesn\'t exist.'; $error_view->setTitle("Error"); $error_view->appendChild('<p>' . $error_body . '</p>'); $content[] = $error_view; } else { $pager = new AphrontPagerView(); $pager->setOffset($request->getInt('offset')); $pager->setURI($request->getRequestURI(), 'offset'); $query = new PhabricatorSearchQuery(); $query->setParameter('type', PhabricatorPHIDConstants::PHID_TYPE_CMIT); $query->setParameter('author', array($user->getPHID())); $query->setParameter('limit', $pager->getPageSize() + 1); $query->setParameter('offset', $pager->getOffset()); $user_link = phutil_render_tag('a', array('href' => '/p/' . $user->getUsername() . '/'), phutil_escape_html($user->getUsername())); $executor = new PhabricatorSearchMySQLExecutor(); $results = $executor->executeSearch($query); $results = $pager->sliceResults($results); $result_phids = ipull($results, 'phid'); $commit_table = self::createCommitTable($result_phids, $user); $list_panel = new AphrontPanelView(); $list_panel->setHeader('Commits by ' . $user_link); $list_panel->appendChild($commit_table); $list_panel->appendChild($pager); $content[] = $list_panel; } return $this->buildStandardPageResponse($content, array('title' => 'Commit List')); }
public function processRequest() { $request = $this->getRequest(); $user = $request->getUser(); if ($this->key) { $query = id(new PhabricatorSearchQuery())->loadOneWhere('queryKey = %s', $this->key); if (!$query) { return new Aphront404Response(); } } else { $query = new PhabricatorSearchQuery(); if ($request->isFormPost()) { $query_str = $request->getStr('query'); $pref_jump = PhabricatorUserPreferences::PREFERENCE_SEARCHBAR_JUMP; if ($request->getStr('jump') != 'no' && $user && $user->loadPreferences()->getPreference($pref_jump, 1)) { $response = PhabricatorJumpNavHandler::jumpPostResponse($query_str); } else { $response = null; } if ($response) { return $response; } else { $query->setQuery($query_str); if ($request->getStr('scope')) { switch ($request->getStr('scope')) { case PhabricatorSearchScope::SCOPE_OPEN_REVISIONS: $query->setParameter('open', 1); $query->setParameter('type', PhabricatorPHIDConstants::PHID_TYPE_DREV); break; case PhabricatorSearchScope::SCOPE_OPEN_TASKS: $query->setParameter('open', 1); $query->setParameter('type', PhabricatorPHIDConstants::PHID_TYPE_TASK); break; case PhabricatorSearchScope::SCOPE_WIKI: $query->setParameter('type', PhabricatorPHIDConstants::PHID_TYPE_WIKI); break; case PhabricatorSearchScope::SCOPE_COMMITS: $query->setParameter('type', PhabricatorPHIDConstants::PHID_TYPE_CMIT); break; default: break; } } else { if (strlen($request->getStr('type'))) { $query->setParameter('type', $request->getStr('type')); } if ($request->getArr('author')) { $query->setParameter('author', $request->getArr('author')); } if ($request->getArr('owner')) { $query->setParameter('owner', $request->getArr('owner')); } if ($request->getInt('open')) { $query->setParameter('open', $request->getInt('open')); } if ($request->getArr('project')) { $query->setParameter('project', $request->getArr('project')); } } $query->save(); return id(new AphrontRedirectResponse())->setURI('/search/' . $query->getQueryKey() . '/'); } } } $options = array('' => 'All Documents') + PhabricatorSearchAbstractDocument::getSupportedTypes(); $status_options = array(0 => 'Open and Closed Documents', 1 => 'Open Documents'); $phids = array_merge($query->getParameter('author', array()), $query->getParameter('owner', array()), $query->getParameter('project', array())); $handles = $this->loadViewerHandles($phids); $author_value = array_select_keys($handles, $query->getParameter('author', array())); $author_value = mpull($author_value, 'getFullName', 'getPHID'); $owner_value = array_select_keys($handles, $query->getParameter('owner', array())); $owner_value = mpull($owner_value, 'getFullName', 'getPHID'); $project_value = array_select_keys($handles, $query->getParameter('project', array())); $project_value = mpull($project_value, 'getFullName', 'getPHID'); $search_form = new AphrontFormView(); $search_form->setUser($user)->setAction('/search/')->appendChild(phutil_render_tag('input', array('type' => 'hidden', 'name' => 'jump', 'value' => 'no')))->appendChild(id(new AphrontFormTextControl())->setLabel('Search')->setName('query')->setValue($query->getQuery()))->appendChild(id(new AphrontFormSelectControl())->setLabel('Document Type')->setName('type')->setOptions($options)->setValue($query->getParameter('type')))->appendChild(id(new AphrontFormSelectControl())->setLabel('Document Status')->setName('open')->setOptions($status_options)->setValue($query->getParameter('open')))->appendChild(id(new AphrontFormTokenizerControl())->setName('author')->setLabel('Author')->setDatasource('/typeahead/common/users/')->setValue($author_value))->appendChild(id(new AphrontFormTokenizerControl())->setName('owner')->setLabel('Owner')->setDatasource('/typeahead/common/searchowner/')->setValue($owner_value)->setCaption('Tip: search for "Up For Grabs" to find unowned documents.'))->appendChild(id(new AphrontFormTokenizerControl())->setName('project')->setLabel('Project')->setDatasource('/typeahead/common/projects/')->setValue($project_value))->appendChild(id(new AphrontFormSubmitControl())->setValue('Search')); $search_panel = new AphrontPanelView(); $search_panel->setHeader('Search Phabricator'); $search_panel->appendChild($search_form); require_celerity_resource('phabricator-search-results-css'); if ($query->getID()) { $limit = 20; $pager = new AphrontPagerView(); $pager->setURI($request->getRequestURI(), 'page'); $pager->setPageSize($limit); $pager->setOffset($request->getInt('page')); $query->setParameter('limit', $limit + 1); $query->setParameter('offset', $pager->getOffset()); $engine = PhabricatorSearchEngineSelector::newSelector()->newEngine(); $results = $engine->executeSearch($query); $results = $pager->sliceResults($results); if (!$request->getInt('page')) { $jump = PhabricatorPHID::fromObjectName($query->getQuery()); if ($jump) { array_unshift($results, $jump); } } if ($results) { $loader = new PhabricatorObjectHandleData($results); $handles = $loader->loadHandles(); $objects = $loader->loadObjects(); $results = array(); foreach ($handles as $phid => $handle) { $view = new PhabricatorSearchResultView(); $view->setHandle($handle); $view->setQuery($query); $view->setObject(idx($objects, $phid)); $results[] = $view->render(); } $results = '<div class="phabricator-search-result-list">' . implode("\n", $results) . '<div class="search-results-pager">' . $pager->render() . '</div>' . '</div>'; } else { $results = '<div class="phabricator-search-result-list">' . '<p class="phabricator-search-no-results">No search results.</p>' . '</div>'; } } else { $results = null; } return $this->buildStandardPageResponse(array($search_panel, $results), array('title' => 'Search Results')); }
private function buildQueryFromRequest() { $request = $this->getRequest(); $user = $request->getUser(); $status = $this->getStatusValueFromRequest(); $group = $this->getGroupValueFromRequest(); $order = $this->getOrderValueFromRequest(); $user_phids = $request->getStrList('users', array($user->getPHID())); if ($this->view == 'projecttriage' || $this->view == 'projectall') { $project_query = new PhabricatorProjectQuery(); $project_query->setViewer($user); $project_query->withMemberPHIDs($user_phids); $projects = $project_query->execute(); $project_phids = mpull($projects, 'getPHID'); } else { $project_phids = $request->getStrList('projects'); } $exclude_project_phids = $request->getStrList('xprojects'); $task_ids = $request->getStrList('tasks'); if ($task_ids) { // We only need the integer portion of each task ID, so get rid of any // non-numeric elements $numeric_task_ids = array(); foreach ($task_ids as $task_id) { $task_id = preg_replace('/[a-zA-Z]+/', '', $task_id); if (!empty($task_id)) { $numeric_task_ids[] = $task_id; } } if (empty($numeric_task_ids)) { $numeric_task_ids = array(null); } $task_ids = $numeric_task_ids; } $owner_phids = $request->getStrList('owners'); $author_phids = $request->getStrList('authors'); $search_string = $request->getStr('search'); $low_priority = $request->getInt('lpriority'); $high_priority = $request->getInt('hpriority'); $page = $request->getInt('offset'); $page_size = self::DEFAULT_PAGE_SIZE; $query = new PhabricatorSearchQuery(); $query->setQuery('<<maniphest>>'); $query->setParameters(array('fullTextSearch' => $search_string, 'view' => $this->view, 'userPHIDs' => $user_phids, 'projectPHIDs' => $project_phids, 'excludeProjectPHIDs' => $exclude_project_phids, 'ownerPHIDs' => $owner_phids, 'authorPHIDs' => $author_phids, 'taskIDs' => $task_ids, 'lowPriority' => $low_priority, 'highPriority' => $high_priority, 'group' => $group, 'order' => $order, 'offset' => $page, 'limit' => $page_size, 'status' => $status)); $unguarded = AphrontWriteGuard::beginScopedUnguardedWrites(); $query->save(); unset($unguarded); return $query; }
private function buildFullTextWhereClause($conn) { if (!$this->fullTextSearch) { return null; } // In doing a fulltext search, we first find all the PHIDs that match the // fulltext search, and then use that to limit the rest of the search $fulltext_query = new PhabricatorSearchQuery(); $fulltext_query->setQuery($this->fullTextSearch); $fulltext_query->setParameter('limit', PHP_INT_MAX); $engine = PhabricatorSearchEngineSelector::newSelector()->newEngine(); $fulltext_results = $engine->executeSearch($fulltext_query); if (empty($fulltext_results)) { $fulltext_results = array(null); } return qsprintf($conn, 'phid IN (%Ls)', $fulltext_results); }
<?php // NOTE: If you need to make any significant updates to this to deal with // future changes to objects, it's probably better to just wipe the whole // migration. This feature doesn't see overwhelming amounts of use, and users // who do use it can recreate their queries fairly easily with the new // interface. By the time this needs to be updated, the vast majority of // users who it impacts will likely have migrated their data already. $table = new ManiphestTask(); $conn_w = $table->establishConnection('w'); $search_table = new PhabricatorSearchQuery(); $search_conn_w = $search_table->establishConnection('w'); // See T1812. This is an old status constant from the time of this migration. $old_open_status = 0; echo "Updating saved Maniphest queries...\n"; $rows = new LiskRawMigrationIterator($conn_w, 'maniphest_savedquery'); foreach ($rows as $row) { $id = $row['id']; echo "Updating query {$id}...\n"; $data = queryfx_one($search_conn_w, 'SELECT parameters FROM %T WHERE queryKey = %s', $search_table->getTableName(), $row['queryKey']); if (!$data) { echo "Unable to locate query data.\n"; continue; } $data = json_decode($data['parameters'], true); if (!is_array($data)) { echo "Unable to decode query data.\n"; continue; } if (idx($data, 'view') != 'custom') { echo "Query is not a custom query.\n";
private function buildQueryFromRequest() { $request = $this->getRequest(); $user = $request->getUser(); $status = $this->getStatusValueFromRequest(); $group = $this->getGroupValueFromRequest(); $order = $this->getOrderValueFromRequest(); $user_phids = $request->getStrList('users', array($user->getPHID())); if ($this->view == 'projecttriage' || $this->view == 'projectall') { $project_query = new PhabricatorProjectQuery(); $project_query->setMembers($user_phids); $projects = $project_query->execute(); $project_phids = mpull($projects, 'getPHID'); } else { $project_phids = $request->getStrList('projects'); } $exclude_project_phids = $request->getStrList('xprojects'); $task_ids = $request->getStrList('tasks'); $owner_phids = $request->getStrList('owners'); $author_phids = $request->getStrList('authors'); $page = $request->getInt('offset'); $page_size = self::DEFAULT_PAGE_SIZE; $query = new PhabricatorSearchQuery(); $query->setQuery('<<maniphest>>'); $query->setParameters(array('view' => $this->view, 'userPHIDs' => $user_phids, 'projectPHIDs' => $project_phids, 'excludeProjectPHIDs' => $exclude_project_phids, 'ownerPHIDs' => $owner_phids, 'authorPHIDs' => $author_phids, 'taskIDs' => $task_ids, 'group' => $group, 'order' => $order, 'offset' => $page, 'limit' => $page_size, 'status' => $status)); $unguarded = AphrontWriteGuard::beginScopedUnguardedWrites(); $query->save(); unset($unguarded); return $query; }
protected function joinRelationship(AphrontDatabaseConnection $conn, PhabricatorSearchQuery $query, $field, $type) { $phids = $query->getParameter($field, array()); if (!$phids) { return null; } $is_existence = false; switch ($type) { case PhabricatorSearchRelationship::RELATIONSHIP_OPEN: $is_existence = true; break; } $sql = qsprintf($conn, '%T AS %C ON %C.phid = document.phid AND %C.relation = %s', id(new PhabricatorSearchDocumentRelationship())->getTableName(), $field, $field, $field, $type); if (!$is_existence) { $sql .= qsprintf($conn, ' AND %C.relatedPHID in (%Ls)', $field, $phids); } return $sql; }
public function executeSearch(PhabricatorSearchQuery $query) { $where = array(); $join = array(); $order = 'ORDER BY documentCreated DESC'; $dao_doc = new PhabricatorSearchDocument(); $dao_field = new PhabricatorSearchDocumentField(); $t_doc = $dao_doc->getTableName(); $t_field = $dao_field->getTableName(); $conn_r = $dao_doc->establishConnection('r'); $q = $query->getQuery(); if (strlen($q)) { $join[] = qsprintf($conn_r, "{$t_field} field ON field.phid = document.phid"); $where[] = qsprintf($conn_r, 'MATCH(corpus) AGAINST (%s IN BOOLEAN MODE)', $q); // When searching for a string, promote user listings above other // listings. $order = qsprintf($conn_r, 'ORDER BY IF(documentType = %s, 0, 1) ASC, MAX(MATCH(corpus) AGAINST (%s)) DESC', 'USER', $q); $field = $query->getParameter('field'); if ($field) { $where[] = qsprintf($conn_r, 'field.field = %s', $field); } } $exclude = $query->getParameter('exclude'); if ($exclude) { $where[] = qsprintf($conn_r, 'document.phid != %s', $exclude); } if ($query->getParameter('type')) { if (strlen($q)) { // TODO: verify that this column actually does something useful in query // plans once we have nontrivial amounts of data. $where[] = qsprintf($conn_r, 'field.phidType = %s', $query->getParameter('type')); } $where[] = qsprintf($conn_r, 'document.documentType = %s', $query->getParameter('type')); } $join[] = $this->joinRelationship($conn_r, $query, 'author', PhabricatorSearchRelationship::RELATIONSHIP_AUTHOR); $join[] = $this->joinRelationship($conn_r, $query, 'open', PhabricatorSearchRelationship::RELATIONSHIP_OPEN); $join[] = $this->joinRelationship($conn_r, $query, 'owner', PhabricatorSearchRelationship::RELATIONSHIP_OWNER); $join[] = $this->joinRelationship($conn_r, $query, 'project', PhabricatorSearchRelationship::RELATIONSHIP_PROJECT); $join[] = $this->joinRelationship($conn_r, $query, 'repository', PhabricatorSearchRelationship::RELATIONSHIP_REPOSITORY); /* $join[] = $this->joinRelationship( $conn_r, $query, 'reviewer', AdjutantRelationship::RELATIONSHIP_REVIEWER); $join[] = $this->joinRelationship( $conn_r, $query, 'subscriber', AdjutantRelationship::RELATIONSHIP_SUBSCRIBER); $join[] = $this->joinRelationship( $conn_r, $query, 'repository', AdjutantRelationship::RELATIONSHIP_REPOSITORY); */ $join = array_filter($join); foreach ($join as $key => $clause) { $join[$key] = ' JOIN ' . $clause; } $join = implode(' ', $join); if ($where) { $where = 'WHERE ' . implode(' AND ', $where); } else { $where = ''; } $offset = (int) $query->getParameter('offset', 0); $limit = (int) $query->getParameter('limit', 25); $hits = queryfx_all($conn_r, 'SELECT document.phid, document.documentType, document.documentTitle, document.documentCreated FROM %T document %Q %Q GROUP BY document.phid %Q LIMIT %d, %d', $t_doc, $join, $where, $order, $offset, $limit); return $hits; }
public function processRequest() { $request = $this->getRequest(); $user = $request->getUser(); if ($this->id) { $query = id(new PhabricatorSearchQuery())->load($this->id); if (!$query) { return new Aphront404Response(); } } else { $query = new PhabricatorSearchQuery(); if ($request->isFormPost()) { $query->setQuery($request->getStr('query')); if (strlen($request->getStr('type'))) { $query->setParameter('type', $request->getStr('type')); } if ($request->getArr('author')) { $query->setParameter('author', $request->getArr('author')); } if ($request->getArr('owner')) { $query->setParameter('owner', $request->getArr('owner')); } if ($request->getInt('open')) { $query->setParameter('open', $request->getInt('open')); } if ($request->getArr('project')) { $query->setParameter('project', $request->getArr('project')); } $query->save(); return id(new AphrontRedirectResponse())->setURI('/search/' . $query->getID() . '/'); } } $more = PhabricatorEnv::getEnvConfig('search.more-document-types', array()); $options = array('' => 'All Documents', PhabricatorPHIDConstants::PHID_TYPE_DREV => 'Differential Revisions', PhabricatorPHIDConstants::PHID_TYPE_CMIT => 'Repository Commits', PhabricatorPHIDConstants::PHID_TYPE_TASK => 'Maniphest Tasks', PhabricatorPHIDConstants::PHID_TYPE_WIKI => 'Phriction Documents', PhabricatorPHIDConstants::PHID_TYPE_USER => 'Phabricator Users') + $more; $status_options = array(0 => 'Open and Closed Documents', 1 => 'Open Documents'); $phids = array_merge($query->getParameter('author', array()), $query->getParameter('owner', array()), $query->getParameter('project', array())); $handles = id(new PhabricatorObjectHandleData($phids))->loadHandles(); $author_value = array_select_keys($handles, $query->getParameter('author', array())); $author_value = mpull($author_value, 'getFullName', 'getPHID'); $owner_value = array_select_keys($handles, $query->getParameter('owner', array())); $owner_value = mpull($owner_value, 'getFullName', 'getPHID'); $project_value = array_select_keys($handles, $query->getParameter('project', array())); $project_value = mpull($project_value, 'getFullName', 'getPHID'); $search_form = new AphrontFormView(); $search_form->setUser($user)->setAction('/search/')->appendChild(id(new AphrontFormTextControl())->setLabel('Search')->setName('query')->setValue($query->getQuery()))->appendChild(id(new AphrontFormSelectControl())->setLabel('Document Type')->setName('type')->setOptions($options)->setValue($query->getParameter('type')))->appendChild(id(new AphrontFormSelectControl())->setLabel('Document Status')->setName('open')->setOptions($status_options)->setValue($query->getParameter('open')))->appendChild(id(new AphrontFormTokenizerControl())->setName('author')->setLabel('Author')->setDatasource('/typeahead/common/users/')->setValue($author_value))->appendChild(id(new AphrontFormTokenizerControl())->setName('owner')->setLabel('Owner')->setDatasource('/typeahead/common/searchowner/')->setValue($owner_value)->setCaption('Tip: search for "Up For Grabs" to find unowned documents.'))->appendChild(id(new AphrontFormTokenizerControl())->setName('project')->setLabel('Project')->setDatasource('/typeahead/common/projects/')->setValue($project_value))->appendChild(id(new AphrontFormSubmitControl())->setValue('Search')); $search_panel = new AphrontPanelView(); $search_panel->setHeader('Search Phabricator'); $search_panel->appendChild($search_form); require_celerity_resource('phabricator-search-results-css'); if ($query->getID()) { $limit = 20; $pager = new AphrontPagerView(); $pager->setURI($request->getRequestURI(), 'page'); $pager->setPageSize($limit); $pager->setOffset($request->getInt('page')); $query->setParameter('limit', $limit + 1); $query->setParameter('offset', $pager->getOffset()); $executor = new PhabricatorSearchMySQLExecutor(); $results = $executor->executeSearch($query); $results = ipull($results, 'phid'); $results = $pager->sliceResults($results); if ($results) { $loader = new PhabricatorObjectHandleData($results); $handles = $loader->loadHandles(); $objects = $loader->loadObjects(); $results = array(); foreach ($handles as $phid => $handle) { $view = new PhabricatorSearchResultView(); $view->setHandle($handle); $view->setQuery($query); $view->setObject($objects[$phid]); $results[] = $view->render(); } $results = '<div class="phabricator-search-result-list">' . implode("\n", $results) . '<div class="search-results-pager">' . $pager->render() . '</div>' . '</div>'; } else { $results = '<div class="phabricator-search-result-list">' . '<p class="phabricator-search-no-results">No search results.</p>' . '</div>'; } } else { $results = null; } return $this->buildStandardPageResponse(array($search_panel, $results), array('title' => 'Results: what')); }
public function executeSearch(PhabricatorSearchQuery $query) { $type = $query->getParameter('type'); if ($type) { $uri = "/phabricator/{$type}/_search"; } else { // Don't use '/phabricator/_search' for the case that there is something // else in the index (for example if 'phabricator' is only an alias to // some bigger index). $types = PhabricatorSearchAbstractDocument::getSupportedTypes(); $uri = '/phabricator/' . implode(',', array_keys($types)) . '/_search'; } try { $response = $this->executeRequest($uri, $this->buildSpec($query)); } catch (HTTPFutureResponseStatusHTTP $ex) { // elasticsearch probably uses Lucene query syntax: // http://lucene.apache.org/core/3_6_1/queryparsersyntax.html // Try literal search if operator search fails. if (!$query->getQuery()) { throw $ex; } $query = clone $query; $query->setQuery(addcslashes($query->getQuery(), '+-&|!(){}[]^"~*?:\\')); $response = $this->executeRequest($uri, $this->buildSpec($query)); } $phids = ipull($response['hits']['hits'], '_id'); return $phids; }