Skip to content

Instantly share code, notes, and snippets.

@ruckus
Created November 29, 2011 23:29
Show Gist options
  • Select an option

  • Save ruckus/1407145 to your computer and use it in GitHub Desktop.

Select an option

Save ruckus/1407145 to your computer and use it in GitHub Desktop.
<?php
// Docs: http://us3.php.net/manual/en/class.sphinxclient.php
$s = new SphinxClient;
$s->setServer("127.0.0.1", 3312);
$s->setMatchMode(SPH_MATCH_EXTENDED);
echo "\nsearch all indexes across all fields for \"wave\"\n";
$result = $s->query("wave", "*");
print_r($result);
echo "\n-------------------------------------------------------------------\n";
echo "\nsearch the media_items and posts indexes across all fields for \"wave\"\n";
$result = $s->query("wave", "media_items,posts");
print_r($result);
echo "\n-------------------------------------------------------------------\n";
echo "\n\nsearch the users index for all fields for \"josh\"\n";
$result = $s->query("josh", "users");
print_r($result);
echo "\n-------------------------------------------------------------------\n";
echo "\nusers firstName field for \"josh\"\n";
$result = $s->query("@firstName josh", "users");
print_r($result);
echo "\n-------------------------------------------------------------------\n";
echo "\nusers firstName field for \"josh\" and @lastName field of bobcat \n";
$result = $s->query("@firstName josh @lastName bobcat", "users");
print_r($result);
?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment