} } else { $words = array(); foreach ($meta_map as $k => $v) { if (preg_match('/keyword\\[\\d+]/', $k)) { preg_match('/\\d+/', $k, $key); $key = $key[0]; $words[$key]['keyword'] = $v; } if (preg_match('/docs\\[\\d+]/', $k)) { preg_match('/\\d+/', $k, $key); $key = $key[0]; $words[$key]['docs'] = $v; } } $suggest = MakePhaseSuggestion($words, $query, $ln_sph); } } $title = 'Demo autocomplete with correction suggestion'; include 'template/header.php'; ?> <div class="container"> <ul class="nav nav-pills"> <li><a href="index.php">Autocomplete on titles</a></li> <li class="active"><a href="suggestcomplete.php">Autocomplete on titles + suggestion</a></li> <li><a href="suggestcompleteexcerpts.php">Autocomplete on titles + suggestion + excerpts</a></li> </ul> <header> <h1>Demo autocomplete with correction suggestion</h1>
} if (count($rows) === 0) { $words = array(); foreach ($meta_map as $k => $v) { if (preg_match('/keyword\\[\\d+]/', $k)) { preg_match('/\\d+/', $k, $key); $key = $key[0]; $words[$key]['keyword'] = $v; } if (preg_match('/docs\\[\\d+]/', $k)) { preg_match('/\\d+/', $k, $key); $key = $key[0]; $words[$key]['docs'] = $v; } } $suggest = MakePhaseSuggestion($words, $term, $ln_sph); if ($suggest !== FALSE) { $app->response->redirect($app->urlFor('autocomplete', array('term' => $suggest))); $app->stop(); } $result[] = ['label' => 'nothing found', 'url' => '#', 'type' => '', 'img' => '/skin/default/img/icon-label.png']; } else { $filterTypeMapping = array_flip($filterTypeMapping); $cl = new SphinxClient(); foreach ($rows as $row) { $excerped = $cl->BuildExcerpts([$row['phrase']], 'slimpdautocomplete', $term); $filterType = $filterTypeMapping[$row['type']]; $entry = ['label' => $excerped[0], 'url' => $filterType === 'track' ? '/searchall/page/1/sort/relevance/desc?q=' . $row['phrase'] : '/library/' . $filterType . '/' . $row['itemid'], 'type' => $filterType, 'typelabel' => $app->ll->str($filterType), 'itemid' => $row['itemid']]; switch ($filterType) { case 'artist': case 'label':