Permalink
Browse files

group_concat does NOT order by so in HA Mobile we get back a LOT of u…

…rlhashes for a search like "cnn" but they get truncated and the urlhashes do not match any in the tiney pool of 5K URLs in the mobile crawls. Instead, do a normal query and do the concat manually.
  • Loading branch information...
1 parent f471586 commit 89dae7e3cb400f364f12efe55a3b2c4f46b7e1cb @stevesouders stevesouders committed May 25, 2016
Showing with 10 additions and 2 deletions.
  1. +10 −2 findurl.php
View
@@ -21,8 +21,16 @@
// First, get all the urlhashes from the "urls" table that match the search term.
// We CAN'T do ordering here because hashes are shared by multiple URLs,
// and all we're transferring from here are the hashes.
-$query = "select group_concat(urlhash) from $gUrlsTable where (urlOrig like '%$term%' or urlFixed like '%$term%');";
-$sUrlhashes = doSimpleQuery($query);
+// This doesn't work because ORDER BY doesn't work and so we miss the most popular urlhashes.
+// $query = "select group_concat(urlhash order by rank asc) from $gUrlsTable where (urlOrig like '%$term%' or urlFixed like '%$term%');";
+$query = "select distinct(urlhash) from $gUrlsTable where (urlOrig like '%$term%' or urlFixed like '%$term%') order by rank asc;";
+$result = doQuery($query);
+$sUrlhashes = "";
+while ( $row = mysql_fetch_assoc($result) ) {
+ $sUrlhashes .= $row['urlhash'] . ",";
+}
+mysql_free_result($result);
+
// It's possible the list ends in "," which is bad (eg, if urlhash is null).
if ( "," === substr($sUrlhashes, -1) ) {

0 comments on commit 89dae7e

Please sign in to comment.