Page Menu
Home
Phabricator
Search
Configure Global Search
Log In
Files
F13252888
D8120.diff
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Award Token
Flag For Later
Size
14 KB
Referenced Files
None
Subscribers
None
D8120.diff
View Options
Index: src/__phutil_library_map__.php
===================================================================
--- src/__phutil_library_map__.php
+++ src/__phutil_library_map__.php
@@ -1941,6 +1941,7 @@
'PhabricatorSavedQueryQuery' => 'applications/search/query/PhabricatorSavedQueryQuery.php',
'PhabricatorScopedEnv' => 'infrastructure/env/PhabricatorScopedEnv.php',
'PhabricatorSearchAbstractDocument' => 'applications/search/index/PhabricatorSearchAbstractDocument.php',
+ 'PhabricatorSearchApplicationSearchEngine' => 'applications/search/query/PhabricatorSearchApplicationSearchEngine.php',
'PhabricatorSearchAttachController' => 'applications/search/controller/PhabricatorSearchAttachController.php',
'PhabricatorSearchBaseController' => 'applications/search/controller/PhabricatorSearchBaseController.php',
'PhabricatorSearchConfigOptions' => 'applications/search/config/PhabricatorSearchConfigOptions.php',
@@ -1950,6 +1951,7 @@
'PhabricatorSearchDocument' => 'applications/search/storage/document/PhabricatorSearchDocument.php',
'PhabricatorSearchDocumentField' => 'applications/search/storage/document/PhabricatorSearchDocumentField.php',
'PhabricatorSearchDocumentIndexer' => 'applications/search/index/PhabricatorSearchDocumentIndexer.php',
+ 'PhabricatorSearchDocumentQuery' => 'applications/search/query/PhabricatorSearchDocumentQuery.php',
'PhabricatorSearchDocumentRelationship' => 'applications/search/storage/document/PhabricatorSearchDocumentRelationship.php',
'PhabricatorSearchEditController' => 'applications/search/controller/PhabricatorSearchEditController.php',
'PhabricatorSearchEngine' => 'applications/search/engine/PhabricatorSearchEngine.php',
@@ -4686,6 +4688,7 @@
1 => 'PhabricatorPolicyInterface',
),
'PhabricatorSavedQueryQuery' => 'PhabricatorCursorPagedPolicyAwareQuery',
+ 'PhabricatorSearchApplicationSearchEngine' => 'PhabricatorApplicationSearchEngine',
'PhabricatorSearchAttachController' => 'PhabricatorSearchBaseController',
'PhabricatorSearchBaseController' => 'PhabricatorController',
'PhabricatorSearchConfigOptions' => 'PhabricatorApplicationConfigOptions',
@@ -4694,6 +4697,7 @@
'PhabricatorSearchDeleteController' => 'PhabricatorSearchBaseController',
'PhabricatorSearchDocument' => 'PhabricatorSearchDAO',
'PhabricatorSearchDocumentField' => 'PhabricatorSearchDAO',
+ 'PhabricatorSearchDocumentQuery' => 'PhabricatorCursorPagedPolicyAwareQuery',
'PhabricatorSearchDocumentRelationship' => 'PhabricatorSearchDAO',
'PhabricatorSearchEditController' => 'PhabricatorSearchBaseController',
'PhabricatorSearchEngineElastic' => 'PhabricatorSearchEngine',
Index: src/applications/home/controller/PhabricatorHomeMainController.php
===================================================================
--- src/applications/home/controller/PhabricatorHomeMainController.php
+++ src/applications/home/controller/PhabricatorHomeMainController.php
@@ -98,9 +98,10 @@
return $response;
} else if ($request->isFormPost()) {
- $query = new PhabricatorSearchQuery();
- $query->setQuery($jump);
- $query->save();
+ $query = id(new PhabricatorSavedQuery())
+ ->setEngineClassName('PhabricatorSearchApplicationSearchEngine')
+ ->setParameter('query', $jump)
+ ->save();
return id(new AphrontRedirectResponse())
->setURI('/search/'.$query->getQueryKey().'/');
Index: src/applications/maniphest/query/ManiphestTaskQuery.php
===================================================================
--- src/applications/maniphest/query/ManiphestTaskQuery.php
+++ src/applications/maniphest/query/ManiphestTaskQuery.php
@@ -406,8 +406,9 @@
// 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 = id(new PhabricatorSavedQuery())
+ ->setEngineClassName('PhabricatorSearchApplicaionSearchEngine')
+ ->setParameter('query', $this->fullTextSearch);
// NOTE: Setting this to something larger than 2^53 will raise errors in
// ElasticSearch, and billions of results won't fit in memory anyway.
Index: src/applications/search/controller/PhabricatorSearchController.php
===================================================================
--- src/applications/search/controller/PhabricatorSearchController.php
+++ src/applications/search/controller/PhabricatorSearchController.php
@@ -21,14 +21,15 @@
$user = $request->getUser();
if ($this->key) {
- $query = id(new PhabricatorSearchQuery())->loadOneWhere(
+ $query = id(new PhabricatorSavedQuery())->loadOneWhere(
'queryKey = %s',
$this->key);
if (!$query) {
return new Aphront404Response();
}
} else {
- $query = new PhabricatorSearchQuery();
+ $query = id(new PhabricatorSavedQuery())
+ ->setEngineClassName('PhabricatorSearchApplicationSearchEngine');
if ($request->isFormPost()) {
$query_str = $request->getStr('query');
@@ -45,7 +46,7 @@
if ($response) {
return $response;
} else {
- $query->setQuery($query_str);
+ $query->setParameter('query', $query_str);
if ($request->getStr('scope')) {
switch ($request->getStr('scope')) {
@@ -101,7 +102,11 @@
}
}
- $query->save();
+ try {
+ $query->save();
+ } catch (AphrontQueryDuplicateKeyException $ex) {
+ // Someone has already executed this query.
+ }
return id(new AphrontRedirectResponse())
->setURI('/search/'.$query->getQueryKey().'/');
}
@@ -157,7 +162,7 @@
id(new AphrontFormTextControl())
->setLabel('Search')
->setName('query')
- ->setValue($query->getQuery()))
+ ->setValue($query->getParameter('query')))
->appendChild(
id(new AphrontFormSelectControl())
->setLabel('Document Type')
@@ -227,7 +232,7 @@
if (!$request->getInt('page')) {
$named = id(new PhabricatorObjectQuery())
->setViewer($user)
- ->withNames(array($query->getQuery()))
+ ->withNames(array($query->getParameter('queyr')))
->execute();
if ($named) {
$results = array_merge(array_keys($named), $results);
Index: src/applications/search/controller/PhabricatorSearchSelectController.php
===================================================================
--- src/applications/search/controller/PhabricatorSearchSelectController.php
+++ src/applications/search/controller/PhabricatorSearchSelectController.php
@@ -16,10 +16,11 @@
$request = $this->getRequest();
$user = $request->getUser();
- $query = new PhabricatorSearchQuery();
+ $query = new PhabricatorSavedQuery();
$query_str = $request->getStr('query');
- $query->setQuery($query_str);
+ $query->setEngineClassName('PhabricatorSearchApplicationSearchEngine');
+ $query->setParameter('query', $query_str);
$query->setParameter('type', $this->type);
switch ($request->getStr('filter')) {
Index: src/applications/search/engine/PhabricatorSearchEngine.php
===================================================================
--- src/applications/search/engine/PhabricatorSearchEngine.php
+++ src/applications/search/engine/PhabricatorSearchEngine.php
@@ -5,8 +5,6 @@
* Base class for Phabricator search engine providers. Each engine must offer
* three capabilities: indexing, searching, and reconstruction (this can be
* stubbed out if an engine can't reasonably do it, it is used for debugging).
- *
- * @group search
*/
abstract class PhabricatorSearchEngine {
@@ -33,9 +31,9 @@
/**
* Execute a search query.
*
- * @param PhabricatorSearchQuery A query to execute.
+ * @param PhabricatorSavedQuery A query to execute.
* @return list A list of matching PHIDs.
*/
- abstract public function executeSearch(PhabricatorSearchQuery $query);
+ abstract public function executeSearch(PhabricatorSavedQuery $query);
}
Index: src/applications/search/engine/PhabricatorSearchEngineElastic.php
===================================================================
--- src/applications/search/engine/PhabricatorSearchEngineElastic.php
+++ src/applications/search/engine/PhabricatorSearchEngineElastic.php
@@ -1,8 +1,5 @@
<?php
-/**
- * @group search
- */
final class PhabricatorSearchEngineElastic extends PhabricatorSearchEngine {
private $uri;
private $timeout;
@@ -94,14 +91,14 @@
return $doc;
}
- private function buildSpec(PhabricatorSearchQuery $query) {
+ private function buildSpec(PhabricatorSavedQuery $query) {
$spec = array();
$filter = array();
- if ($query->getQuery() != '') {
+ if ($query->getParameter('query') != '') {
$spec[] = array(
'field' => array(
- 'field.corpus' => $query->getQuery(),
+ 'field.corpus' => $query->getParameter('query'),
),
);
}
@@ -167,7 +164,7 @@
);
}
- if (!$query->getQuery()) {
+ if (!$query->getParameter('query')) {
$spec['sort'] = array(
array('dateCreated' => 'desc'),
);
@@ -179,7 +176,7 @@
return $spec;
}
- public function executeSearch(PhabricatorSearchQuery $query) {
+ public function executeSearch(PhabricatorSavedQuery $query) {
$type = $query->getParameter('type');
if ($type) {
$uri = "/phabricator/{$type}/_search";
@@ -197,11 +194,13 @@
// 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()) {
+ if (!$query->getParameter('query')) {
throw $ex;
}
$query = clone $query;
- $query->setQuery(addcslashes($query->getQuery(), '+-&|!(){}[]^"~*?:\\'));
+ $query->setQuery(
+ addcslashes(
+ $query->getParameter('query'), '+-&|!(){}[]^"~*?:\\'));
$response = $this->executeRequest($uri, $this->buildSpec($query));
}
Index: src/applications/search/engine/PhabricatorSearchEngineMySQL.php
===================================================================
--- src/applications/search/engine/PhabricatorSearchEngineMySQL.php
+++ src/applications/search/engine/PhabricatorSearchEngineMySQL.php
@@ -142,7 +142,7 @@
return $adoc;
}
- public function executeSearch(PhabricatorSearchQuery $query) {
+ public function executeSearch(PhabricatorSavedQuery $query) {
$where = array();
$join = array();
@@ -156,7 +156,7 @@
$conn_r = $dao_doc->establishConnection('r');
- $q = $query->getQuery();
+ $q = $query->getParameter('query');
if (strlen($q)) {
$join[] = qsprintf(
@@ -281,7 +281,7 @@
protected function joinRelationship(
AphrontDatabaseConnection $conn,
- PhabricatorSearchQuery $query,
+ PhabricatorSavedQuery $query,
$field,
$type) {
Index: src/applications/search/query/PhabricatorSearchApplicationSearchEngine.php
===================================================================
--- /dev/null
+++ src/applications/search/query/PhabricatorSearchApplicationSearchEngine.php
@@ -0,0 +1,49 @@
+<?php
+
+final class PhabricatorSearchApplicationSearchEngine
+ extends PhabricatorApplicationSearchEngine {
+
+ public function buildSavedQueryFromRequest(AphrontRequest $request) {
+ $saved = new PhabricatorSavedQuery();
+
+ return $saved;
+ }
+
+ public function buildQueryFromSavedQuery(PhabricatorSavedQuery $saved) {
+ $query = id(new PhabricatorSearchDocumentQuery());
+
+ return $query;
+ }
+
+ public function buildSearchForm(
+ AphrontFormView $form,
+ PhabricatorSavedQuery $saved_query) {
+ return;
+ }
+
+ protected function getURI($path) {
+ return '/search/'.$path;
+ }
+
+ public function getBuiltinQueryNames() {
+ $names = array(
+ 'all' => pht('All Documents'),
+ );
+
+ return $names;
+ }
+
+ public function buildSavedQueryFromBuiltin($query_key) {
+
+ $query = $this->newSavedQuery();
+ $query->setQueryKey($query_key);
+
+ switch ($query_key) {
+ case 'all':
+ return $query;
+ }
+
+ return parent::buildSavedQueryFromBuiltin($query_key);
+ }
+
+}
Index: src/applications/search/query/PhabricatorSearchDocumentQuery.php
===================================================================
--- /dev/null
+++ src/applications/search/query/PhabricatorSearchDocumentQuery.php
@@ -0,0 +1,14 @@
+<?php
+
+final class PhabricatorSearchDocumentQuery
+ extends PhabricatorCursorPagedPolicyAwareQuery {
+
+ protected function loadPage() {
+ return array();
+ }
+
+ public function getQueryApplicationClass() {
+ return 'PhabricatorApplicationSearch';
+ }
+
+}
Index: src/applications/search/storage/PhabricatorSearchQuery.php
===================================================================
--- src/applications/search/storage/PhabricatorSearchQuery.php
+++ src/applications/search/storage/PhabricatorSearchQuery.php
@@ -1,7 +1,18 @@
<?php
/**
- * @group search
+ * Obsolete storage for saved search parameters. This class is no longer used;
+ * it was obsoleted by the introduction of {@class:PhabricatorSavedQuery}.
+ *
+ * This class is retained only because one of the migrations
+ * (`20130913.maniphest.1.migratesearch.php`) relies on it to migrate old saved
+ * Maniphest searches to new infrastructure. We can remove this class and the
+ * corresponding migration after installs have had a reasonable amount of time
+ * to perform it.
+ *
+ * TODO: Remove this class after 2014-09-13, roughly.
+ *
+ * @deprecated
*/
final class PhabricatorSearchQuery extends PhabricatorSearchDAO {
Index: src/applications/search/view/PhabricatorSearchResultView.php
===================================================================
--- src/applications/search/view/PhabricatorSearchResultView.php
+++ src/applications/search/view/PhabricatorSearchResultView.php
@@ -1,8 +1,5 @@
<?php
-/**
- * @group search
- */
final class PhabricatorSearchResultView extends AphrontView {
private $handle;
@@ -14,7 +11,7 @@
return $this;
}
- public function setQuery(PhabricatorSearchQuery $query) {
+ public function setQuery(PhabricatorSavedQuery $query) {
$this->query = $query;
return $this;
}
@@ -84,7 +81,7 @@
return $str;
}
- $query = $this->query->getQuery();
+ $query = $this->query->getParameter('query');
$quoted_regexp = '/"([^"]*)"/';
$matches = array(1 => array());
File Metadata
Details
Attached
Mime Type
text/plain
Expires
May 26 2024, 2:10 AM (4 w, 3 d ago)
Storage Engine
blob
Storage Format
Encrypted (AES-256-CBC)
Storage Handle
6299683
Default Alt Text
D8120.diff (14 KB)
Attached To
Mode
D8120: Partially use ApplicationSearch in main search
Attached
Detach File
Event Timeline
Log In to Comment