Page MenuHomePhabricator
Paste P2060

example_query.sql
ActivePublic

Authored by epriestley on Jun 9 2017, 10:52 PM.
Tags
None
Referenced Files
F4996011: example_query.sql
Jun 9 2017, 10:52 PM
Subscribers
None
USE phabricator_search;
SELECT documentPHID, MAX(fieldScore) AS documentScore FROM (SELECT document.phid AS documentPHID, IF(field.field = 'titl', 1024, 0) + MATCH(corpus, stemmedCorpus) AGAINST ('\"http\"' IN BOOLEAN MODE) AS fieldScore FROM `search_document` document JOIN `search_documentfield` field ON field.phid = document.phid JOIN `search_documentrelationship` AS `authorPHIDs` ON `authorPHIDs`.phid = document.phid AND `authorPHIDs`.relation = 'auth' AND `authorPHIDs`.relatedPHID in ('PHID-USER-ba8aeea1b3fe2853d6bb') JOIN `search_documentrelationship` AS `statuses` ON `statuses`.phid = document.phid AND `statuses`.relation = 'open' WHERE MATCH(corpus, stemmedCorpus) AGAINST ('\"http\"' IN BOOLEAN MODE) AND field.phidType IN ('DREV') AND document.documentType IN ('DREV') LIMIT 1000) query JOIN `search_document` root ON query.documentPHID = root.phid GROUP BY documentPHID ORDER BY documentScore DESC LIMIT 0, 100;