/** \brief Gets relevant articles from database based on keys * \param keys The keys to match against the keys in the database * \returns Top 4 article matches, each contains the url to the file, a header * and a short description (sorted wizards first, articles second) */ function searchArticles($keys) { $raw_json = file_get_contents("http://localhost:8983/solr/help_data/query?q=" . $keys); $json = json_decode($raw_json, true); $response = $json['response']; $articles = null; if ($response['numFound'] > 0) { $docs = $response['docs']; $wizards = array(); $regulars = array(); foreach ($docs as $doc) { $article = new Article($doc); if ($article->getArticleType() === "wizard") { $wizards[] = $article; } else { $regulars[] = $article; } } $sorted = $wizards; foreach ($regulars as $regular) { $sorted[] = $regular; } $articles = new Requests($sorted, Requests::Articles); } return $articles; }