Book Image

Sphinx Search Beginner's Guide

By : Abbas Ali
Book Image

Sphinx Search Beginner's Guide

By: Abbas Ali

Overview of this book

Table of Contents (15 chapters)
Sphinx Search
Credits
About the Author
Acknowledgement
About the Reviewers
www.PacktPub.com
Preface

Time for action - weighting search results


  1. 1. Modify display_results.php (created earlier) and add the code as highlighted next:

    if (count($cats)) {
    print "<br />Categories: " . implode(', ', $cats);
    }
    print "<br />Weight: " . $result['weight'];
    print "<hr />";
    
  2. 2. Create a PHP script search_weighting.php in your webroot containing the following code:

    <?php
    // Include the api class
    require('sphinxapi.php');
    // Include the file which contains the function to display results
    require_once('display_results.php');
    $client = new SphinxClient();
    $client->SetServer('localhost', 9312);
    $client->SetConnectTimeout(1);
    $client->SetArrayResult(true);
    $client->SetMatchMode(SPH_MATCH_ANY);
    display_results(
    $client->Query('php language framework'),
    'MATCH ANY');
    $client->SetMatchMode(SPH_MATCH_BOOLEAN);
    display_results(
    $client->Query('php | framework'),
    'BOOLEAN');
    $client->SetMatchMode(SPH_MATCH_EXTENDED2);
    display_results(
    $client->Query('@* php | @* framework...