1. Modify the
function do_search()
insearch.php
and add the following highlighted code:function do_search($q, $author, $categories) { global $dbh, $viewVars; // Include the api class require('sphinxapi.php'); $client = new SphinxClient(); // Set search options $client->SetServer('localhost', 9312); $client->SetConnectTimeout(1); $client->SetArrayResult(true); // Set the mode to SPH_MATCH_EXTENDED2 $client->SetMatchMode(SPH_MATCH_EXTENDED2); // Match the search term against title and description $query = "@(title,description) ($q)"; // If we have author then match it against author field if (!empty($author)) { $query .= "@author $author"; } // If categories were selected then filter the results if (!empty($categories)) { $client->SetFilter('category_id', $categories); } // Fire the search query against feed-items index (main index) $viewVars['results'] = $client->Query($query, 'feed-items'); $viewVars['items'] = array...
Sphinx Search Beginner's Guide
By :
Sphinx Search Beginner's Guide
By:
Overview of this book
Table of Contents (15 chapters)
Sphinx Search
Credits
About the Author
Acknowledgement
About the Reviewers
www.PacktPub.com
Preface
Free Chapter
Setting Up Sphinx
Getting Started
Indexing
Searching
Feed Search
Property Search
Sphinx Configuration
Customer Reviews