Suppression Repertoire test
This commit is contained in:
parent
81ff127c7a
commit
4b135c0205
@ -1,187 +0,0 @@
|
||||
<?
|
||||
if (!isset($_REQUEST['typeRecherche']) || ( $_REQUEST['typeRecherche']<>'exacte' &&
|
||||
$_REQUEST['typeRecherche']<>'approx') )
|
||||
$_REQUEST['typeRecherche']='exacte';
|
||||
|
||||
if (!isset($_REQUEST['nbRep']) || $_REQUEST['nbRep']<25 || $_REQUEST['nbRep']>200 )
|
||||
$_REQUEST['nbRep']=25;
|
||||
if (!isset($_REQUEST['nom'])) $_REQUEST['nom']='';
|
||||
if (!isset($_REQUEST['prenom'])) $_REQUEST['prenom']='';
|
||||
if (!isset($_REQUEST['codePostal'])) $_REQUEST['codePostal']='';
|
||||
?>
|
||||
<form action="./?action=rechercher" method="POST">
|
||||
<input type="hidden" name="submitted" value="1">
|
||||
<table>
|
||||
<tr><td><i>Informations sur la personne</i></td><td> </td></tr>
|
||||
<tr><td><b>NOM *</b></td><td><input type="text" name="nom" value="<?=$_REQUEST['nom']?>"></td></tr>
|
||||
<tr><td>Prénom *</td><td><input type="text" name="prenom" value="<?=$_REQUEST['prenom']?>"></td></tr>
|
||||
<tr><td>Département ou Code Postal de résidence *</td><td><input type="text" name="codePostal" value="<?=$_REQUEST['codePostal']?>"></td></tr>
|
||||
<tr><td>Civilité</td><td><input type="radio" name="civilite" value="Mlle"> Mlle
|
||||
<input type="radio" name="civilite" value="Mme"> Mme
|
||||
<input type="radio" name="civilite" value="M"> M</td></tr>
|
||||
<tr><td>Date de Naissance *</td><td><input type="text" name="naissJJ" size="3" maxlength="2"> / <input type="text" name="naissMM" size="3" maxlength="2"> / <input type="text" name="naissAA" size="5" maxlength="4"></td></tr>
|
||||
<tr><td>Ville de Naissance</td><td><input type="text" name="naissVille"></td></tr>
|
||||
<tr><td>Département de Naissance</td><td><input type="text" name="naissDept"></td></tr>
|
||||
<tr><td>Pays de Naissance</td><td><input type="text" name="naissPays"></td></tr>
|
||||
<tr><td>Adresse de résidence *</td><td><input type="text" name="adresse"></td></tr>
|
||||
<tr><td>Ville de résidence *</td><td><input type="text" name="adresseVille"></td></tr>
|
||||
<tr><td>Montant du crédit demandé *</td><td><input type="text" name="creditDemande"></td></tr>
|
||||
<tr><td>SIREN si entrepreneur individuel</td><td><input type="text" name="siren"></td></tr>
|
||||
<tr><td>RIB</td><td><input type="text" name="siren"></td></tr>
|
||||
<tr><td>Téléphone Domicile</td><td><input type="text" name="telephoneMaison"> <i>Liste rouge <input type="radio" name="listeRouge" value="Oui"> Oui <input type="radio" name="listeRouge" value="Non"> Non</td></tr>
|
||||
<tr><td>Téléphone Professionel</td><td><input type="text" name="telephonePro"></td></tr>
|
||||
<tr><td>Téléphone Portable</td><td><input type="text" name="telephonePort"></td></tr>
|
||||
<tr><td><i>Informations complémentaires</i></td><td> </td></tr>
|
||||
<tr><td>Nom de l'employeur</td><td><input type="text" name="employeurNom"></td></tr>
|
||||
<tr><td>Adresse de l'employeur</td><td><input type="text" name="employeurAdresse"></td></tr>
|
||||
<tr><td>Code Postal de l'employeur</td><td><input type="text" name="employeurCP"></td></tr>
|
||||
<tr><td>Ville de l'employeur</td><td><input type="text" name="employeurVille"></td></tr>
|
||||
<tr><td> </td><td> </td></tr>
|
||||
<tr><td>Type de recherche</td><td><input type="radio" <?if ($_REQUEST['typeRecherche']=='exacte') echo 'CHECKED';?> name="typeRecherche" value="exacte">Exacte <input type="radio" <?if ($_REQUEST['typeRecherche']=='approx') echo 'CHECKED';?> name="typeRecherche" value="approx">Approchante</td></tr>
|
||||
<tr><td>Nombre de résultats</td><td><select name="nbRep"><option value="25">25</option><option value="50">50</option><option value="100">100</option><option value="200">200</option></select></td></tr>
|
||||
</table>
|
||||
<input type="submit" value="Valider"> <input type="reset" value="RAZ">
|
||||
</form>
|
||||
<?php
|
||||
include_once('/var/www/includes/mysql.php');
|
||||
$con = mysql_pconnect('localhost', 'root', 'bzh4231*');
|
||||
if (!($con === false)) {
|
||||
if (mysql_select_db('npaipp', $con) === false)
|
||||
die('Could not select database: ' . mysql_error());
|
||||
}
|
||||
|
||||
require ( "sphinxapi.php" );
|
||||
|
||||
//die ( "usage: php -f test.php [--any] <word [word [word [...]]]> [--group <group>] [-p <port>] [-i <index>]\n" );
|
||||
|
||||
$q = $_REQUEST['nom'].' '.$_REQUEST['prenom'];
|
||||
$any = false; // si false $index='xxx'
|
||||
$port = 3312;
|
||||
if ($_REQUEST['typeRecherche']=='exacte')
|
||||
$index="annuaire_pp";
|
||||
else
|
||||
$index="annuaire_pp_shx";
|
||||
$nbRep=$_REQUEST['nbRep'];
|
||||
|
||||
////////////
|
||||
// do query
|
||||
////////////
|
||||
|
||||
$cl = new SphinxClient ();
|
||||
$cl->SetServer ( "localhost", $port );
|
||||
$cl->SetLimits (0, $nbRep);
|
||||
$cl->SetWeights ( array ( 100, 1 ) );
|
||||
$cl->SetMatchMode ( $any ? SPH_MATCH_ANY : SPH_MATCH_ALL );
|
||||
if ( isset($_REQUEST['codePostal']) && $_REQUEST['codePostal']<>'' ) {
|
||||
$tailleCP=strlen($_REQUEST['codePostal']);
|
||||
if ($tailleCP>1 && $tailleCP<4) $cl->SetFilter("departement", array(0=>$_REQUEST['codePostal']));
|
||||
elseif ($tailleCP==5) $cl->SetFilter("codepostal", array(0=>$_REQUEST['codePostal']));
|
||||
}
|
||||
if ( isset($_REQUEST['telephoneMaison']) && $_REQUEST['telephoneMaison']<>'' ) {
|
||||
$cl->SetFilter("tel", array(0=>$_REQUEST['telephoneMaison']));
|
||||
}
|
||||
$res = $cl->Query ( $q, $index );
|
||||
|
||||
////////////////
|
||||
// print me out
|
||||
////////////////
|
||||
|
||||
if ( $res===false )
|
||||
{
|
||||
print "Query failed: " . $cl->GetLastError() . ".\n";
|
||||
|
||||
} else
|
||||
{
|
||||
if ( $cl->GetLastWarning() )
|
||||
print "WARNING: " . $cl->GetLastWarning() . "\n\n";
|
||||
|
||||
print "Query '$q' retrieved $res[total] of $res[total_found] matches in $res[time] sec.<br/>";
|
||||
print "<h3>Query stats</h3><ul>";
|
||||
if ( is_array($res["words"]) )
|
||||
foreach ( $res["words"] as $word => $info )
|
||||
print "<li>'$word' found $info[hits] times in $info[docs] documents</li>";
|
||||
print "</ul>";
|
||||
|
||||
if ( is_array($res["matches"]) )
|
||||
{
|
||||
$n = 1;
|
||||
print "<h3>Reponses :</h3><ul>";
|
||||
foreach ( $res["matches"] as $doc => $docinfo )
|
||||
{
|
||||
// print "<li>$n. doc_id=$doc, weight=$docinfo[weight]<br/>";
|
||||
// foreach ( $res["attrs"] as $attrname => $attrtype )
|
||||
// {
|
||||
$info=mysql_select('particuliers', 'Nom, Adresse, CodePostal, Ville, Tel, Fax', "id=$doc");
|
||||
$personne=$info[0];
|
||||
echo '<li><i>'. $n .'.</i> '. $personne['Nom'] .' ('. $docinfo[weight] .' %)<br/>';
|
||||
echo $personne['Adresse'] .'<br/>';
|
||||
echo $personne['CodePostal'] .' '. $personne['Ville'] .'<br/>';
|
||||
if ($personne['Tel']<>'') echo 'Tél : '.$personne['Tel'].'<br/>';
|
||||
if ($personne['Fax']<>'') echo 'Fax : '.$personne['Fax'].'<br/>';
|
||||
echo "</li>\n";
|
||||
$n++;
|
||||
|
||||
/* $value = $docinfo["attrs"][$attrname];
|
||||
if ( $attrtype==SPH_ATTR_TIMESTAMP )
|
||||
$value = date ( "Y-m-d H:i:s", $value );
|
||||
print ", $attrname=$value";
|
||||
}
|
||||
print "</li>";*/
|
||||
//$n++;
|
||||
}
|
||||
print "</ul>";
|
||||
}
|
||||
echo '<!--';
|
||||
print_r($res);
|
||||
echo '-->';
|
||||
|
||||
if ($_POST['submitted']) {
|
||||
print_r($_POST);
|
||||
|
||||
/* Actions à effectuer :
|
||||
|
||||
// 1. Vérification de l'existance du NOM, Prénom et Adresse dans Annuaire (/30 points)
|
||||
1.1. Si NOM+Prénom à l'adresse ==> OK 30 points
|
||||
1.2. Si NOM sans prénom à l'adresse ==> OK 25 points
|
||||
1.3. Si quelqu'un dans annuaire à l'adresse 10 points
|
||||
1.4. Si pas d'adresse 0 point
|
||||
|
||||
// Si 1.2 ==> 2
|
||||
// Si 1.3 ==> 2 + 3
|
||||
// Si 1.4 ==> 2 + 3 + 4
|
||||
|
||||
// 2. Vérifier si le prénom existe dans la table des prénoms (/ 3 points)
|
||||
2.1. Si le prénom existe OK 2 points
|
||||
2.2. Sinon valeur approchante 1 point
|
||||
2.3. Sinon ?????????? 0 point
|
||||
|
||||
// 3. Vérifier si le nom existe dans la table des noms (/ 3 points)
|
||||
1.1. Si le nom existe OK 2 points
|
||||
1.2. Sinon valeur approchante 1 point
|
||||
1.3. Sinon 0 point
|
||||
|
||||
// 4. Recherche de l'existance de l'adresse / ville (/ 5 points)
|
||||
2.1. Si adresse complète existe 5 points
|
||||
2.2. Si adresse sans n° 3 points
|
||||
2.3. Si approchant 2 points
|
||||
2.4. Si ville sans l'adresse 0 point
|
||||
|
||||
//10. Vérifier si le prénom est logique avec les l'age moyen des personnes portant ce prénom (/ 3 points)
|
||||
2.4.1. Si logique OK 2 points
|
||||
2.4.2. Si approchant 1 point
|
||||
2.4.3. Sinon 0 point
|
||||
|
||||
|
||||
3.3.1 Vérification dans le pages blanches
|
||||
|
||||
// 3. Si un téléphone est communiqué et qu'absence de liste rouge : (30 points)
|
||||
3.1. Vérifier la concordance NOM, Prénom, Adresse, Téléphonesi OK 30 point
|
||||
|
||||
Enregistrer chaque requête
|
||||
et les informations communqiuées par le client
|
||||
*/
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
?>
|
@ -1,157 +0,0 @@
|
||||
<?php
|
||||
|
||||
//
|
||||
// $Id: test.php 1103 2008-01-24 18:42:57Z shodan $
|
||||
//
|
||||
|
||||
require ( "sphinxapi.php" );
|
||||
|
||||
//////////////////////
|
||||
// parse command line
|
||||
//////////////////////
|
||||
|
||||
// for very old PHP versions, like at my home test server
|
||||
if ( is_array($argv) && !isset($_SERVER["argv"]) )
|
||||
$_SERVER["argv"] = $argv;
|
||||
unset ( $_SERVER["argv"][0] );
|
||||
|
||||
// build query
|
||||
if ( !is_array($_SERVER["argv"]) || empty($_SERVER["argv"]) )
|
||||
{
|
||||
print ( "Usage: php -f test.php [OPTIONS] query words\n\n" );
|
||||
print ( "Options are:\n" );
|
||||
print ( "-h, --host <HOST>\tconnect to searchd at host HOST\n" );
|
||||
print ( "-p, --port\t\tconnect to searchd at port PORT\n" );
|
||||
print ( "-i, --index <IDX>\tsearch through index(es) specified by IDX\n" );
|
||||
print ( "-s, --sortby <CLAUSE>\tsort matches by 'CLAUSE' in sort_extended mode\n" );
|
||||
print ( "-S, --sortexpr <EXPR>\tsort matches by 'EXPR' DESC in sort_expr mode\n" );
|
||||
print ( "-a, --any\t\tuse 'match any word' matching mode\n" );
|
||||
print ( "-b, --boolean\t\tuse 'boolean query' matching mode\n" );
|
||||
print ( "-e, --extended\t\tuse 'extended query' matching mode\n" );
|
||||
print ( "-ph,--phrase\t\tuse 'exact phrase' matching mode\n" );
|
||||
print ( "-f, --filter <ATTR>\tfilter by attribute 'ATTR' (default is 'group_id')\n" );
|
||||
print ( "-v, --value <VAL>\tadd VAL to allowed 'group_id' values list\n" );
|
||||
print ( "-g, --groupby <EXPR>\tgroup matches by 'EXPR'\n" );
|
||||
print ( "-gs,--groupsort <EXPR>\tsort groups by 'EXPR'\n" );
|
||||
print ( "-d, --distinct <ATTR>\tcount distinct values of 'ATTR''\n" );
|
||||
print ( "-l, --limit <COUNT>\tretrieve COUNT matches (default: 20)\n" );
|
||||
exit;
|
||||
}
|
||||
|
||||
$args = array();
|
||||
foreach ( $_SERVER["argv"] as $arg )
|
||||
$args[] = $arg;
|
||||
|
||||
$q = "";
|
||||
$mode = SPH_MATCH_ALL;
|
||||
$host = "localhost";
|
||||
$port = 3312;
|
||||
$index = "*";
|
||||
$groupby = "";
|
||||
$groupsort = "@group desc";
|
||||
$filter = "group_id";
|
||||
$filtervals = array();
|
||||
$distinct = "";
|
||||
$sortby = "";
|
||||
$limit = 20;
|
||||
$ranker = SPH_RANK_PROXIMITY_BM25;
|
||||
for ( $i=0; $i<count($args); $i++ )
|
||||
{
|
||||
$arg = $args[$i];
|
||||
|
||||
if ( $arg=="-h" || $arg=="--host" ) $host = $args[++$i];
|
||||
else if ( $arg=="-p" || $arg=="--port" ) $port = (int)$args[++$i];
|
||||
else if ( $arg=="-i" || $arg=="--index" ) $index = $args[++$i];
|
||||
else if ( $arg=="-s" || $arg=="--sortby" ) { $sortby = $args[++$i]; $sortexpr = ""; }
|
||||
else if ( $arg=="-S" || $arg=="--sortexpr" ) { $sortexpr = $args[++$i]; $sortby = ""; }
|
||||
else if ( $arg=="-a" || $arg=="--any" ) $mode = SPH_MATCH_ANY;
|
||||
else if ( $arg=="-b" || $arg=="--boolean" ) $mode = SPH_MATCH_BOOLEAN;
|
||||
else if ( $arg=="-e" || $arg=="--extended" ) $mode = SPH_MATCH_EXTENDED;
|
||||
else if ( $arg=="-e2" ) $mode = SPH_MATCH_EXTENDED2;
|
||||
else if ( $arg=="-ph"|| $arg=="--phrase" ) $mode = SPH_MATCH_PHRASE;
|
||||
else if ( $arg=="-f" || $arg=="--filter" ) $filter = $args[++$i];
|
||||
else if ( $arg=="-v" || $arg=="--value" ) $filtervals[] = $args[++$i];
|
||||
else if ( $arg=="-g" || $arg=="--groupby" ) $groupby = $args[++$i];
|
||||
else if ( $arg=="-gs"|| $arg=="--groupsort" ) $groupsort = $args[++$i];
|
||||
else if ( $arg=="-d" || $arg=="--distinct" ) $distinct = $args[++$i];
|
||||
else if ( $arg=="-l" || $arg=="--limit" ) $limit = (int)$args[++$i];
|
||||
else if ( $arg=="-r" )
|
||||
{
|
||||
$arg = strtolower($args[++$i]);
|
||||
if ( $arg=="bm25" ) $ranker = SPH_RANK_BM25;
|
||||
if ( $arg=="none" ) $ranker = SPH_RANK_NONE;
|
||||
if ( $arg=="wordcount" )$ranker = SPH_RANK_WORDCOUNT;
|
||||
}
|
||||
else
|
||||
$q .= $args[$i] . " ";
|
||||
}
|
||||
|
||||
////////////
|
||||
// do query
|
||||
////////////
|
||||
|
||||
$cl = new SphinxClient ();
|
||||
$cl->SetServer ( $host, $port );
|
||||
$cl->SetWeights ( array ( 100, 1 ) );
|
||||
$cl->SetMatchMode ( $mode );
|
||||
if ( count($filtervals) ) $cl->SetFilter ( $filter, $filtervals );
|
||||
if ( $groupby ) $cl->SetGroupBy ( $groupby, SPH_GROUPBY_ATTR, $groupsort );
|
||||
if ( $sortby ) $cl->SetSortMode ( SPH_SORT_EXTENDED, $sortby );
|
||||
if ( $sortexpr ) $cl->SetSortMode ( SPH_SORT_EXPR, $sortexpr );
|
||||
if ( $distinct ) $cl->SetGroupDistinct ( $distinct );
|
||||
if ( $limit ) $cl->SetLimits ( 0, $limit, ( $limit>1000 ) ? $limit : 1000 );
|
||||
$cl->SetRankingMode ( $ranker );
|
||||
$cl->SetArrayResult ( true );
|
||||
$res = $cl->Query ( $q, $index );
|
||||
|
||||
////////////////
|
||||
// print me out
|
||||
////////////////
|
||||
|
||||
if ( $res===false )
|
||||
{
|
||||
print "Query failed: " . $cl->GetLastError() . ".\n";
|
||||
|
||||
} else
|
||||
{
|
||||
if ( $cl->GetLastWarning() )
|
||||
print "WARNING: " . $cl->GetLastWarning() . "\n\n";
|
||||
|
||||
print "Query '$q' retrieved $res[total] of $res[total_found] matches in $res[time] sec.\n";
|
||||
print "Query stats:\n";
|
||||
if ( is_array($res["words"]) )
|
||||
foreach ( $res["words"] as $word => $info )
|
||||
print " '$word' found $info[hits] times in $info[docs] documents\n";
|
||||
print "\n";
|
||||
|
||||
if ( is_array($res["matches"]) )
|
||||
{
|
||||
$n = 1;
|
||||
print "Matches:\n";
|
||||
foreach ( $res["matches"] as $docinfo )
|
||||
{
|
||||
print "$n. doc_id=$docinfo[id], weight=$docinfo[weight]";
|
||||
foreach ( $res["attrs"] as $attrname => $attrtype )
|
||||
{
|
||||
$value = $docinfo["attrs"][$attrname];
|
||||
if ( $attrtype & SPH_ATTR_MULTI )
|
||||
{
|
||||
$value = "(" . join ( ",", $value ) .")";
|
||||
} else
|
||||
{
|
||||
if ( $attrtype==SPH_ATTR_TIMESTAMP )
|
||||
$value = date ( "Y-m-d H:i:s", $value );
|
||||
}
|
||||
print ", $attrname=$value";
|
||||
}
|
||||
print "\n";
|
||||
$n++;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//
|
||||
// $Id: test.php 1103 2008-01-24 18:42:57Z shodan $
|
||||
//
|
||||
|
||||
?>
|
@ -1,53 +0,0 @@
|
||||
<?php
|
||||
|
||||
//
|
||||
// $Id: test2.php 910 2007-11-16 11:43:46Z shodan $
|
||||
//
|
||||
|
||||
require ( "sphinxapi.php" );
|
||||
|
||||
$docs = array
|
||||
(
|
||||
"this is my test text to be highlighted, and for the sake of the testing we need to pump its length somewhat",
|
||||
"another test text to be highlighted, below limit",
|
||||
"test number three, without phrase match",
|
||||
"final test, not only without phrase match, but also above limit and with swapped phrase text test as well",
|
||||
);
|
||||
$words = "test text";
|
||||
$index = "test1";
|
||||
$opts = array
|
||||
(
|
||||
"before_match" => "<b>",
|
||||
"after_match" => "</b>",
|
||||
"chunk_separator" => " ... ",
|
||||
"limit" => 60,
|
||||
"around" => 3,
|
||||
);
|
||||
|
||||
foreach ( array(0,1) as $exact )
|
||||
{
|
||||
$opts["exact_phrase"] = $exact;
|
||||
print "exact_phrase=$exact\n";
|
||||
|
||||
$cl = new SphinxClient ();
|
||||
$res = $cl->BuildExcerpts ( $docs, $index, $words, $opts );
|
||||
if ( !$res )
|
||||
{
|
||||
die ( "ERROR: " . $cl->GetLastError() . ".\n" );
|
||||
} else
|
||||
{
|
||||
$n = 0;
|
||||
foreach ( $res as $entry )
|
||||
{
|
||||
$n++;
|
||||
print "n=$n, res=$entry\n";
|
||||
}
|
||||
print "\n";
|
||||
}
|
||||
}
|
||||
|
||||
//
|
||||
// $Id: test2.php 910 2007-11-16 11:43:46Z shodan $
|
||||
//
|
||||
|
||||
?>
|
@ -1,44 +0,0 @@
|
||||
<?php
|
||||
|
||||
//
|
||||
// $Id: test2.php,v 1.4 2006/11/26 12:24:21 shodan Exp $
|
||||
//
|
||||
|
||||
require ( "sphinxapi.php" );
|
||||
|
||||
$docs = array
|
||||
(
|
||||
"this is my test text to be highlighted",
|
||||
"this is another test text to be highlighted",
|
||||
);
|
||||
$words = "test text";
|
||||
$index = "test1";
|
||||
$opts = array
|
||||
(
|
||||
"before_match" => "<b>",
|
||||
"after_match" => "</b>",
|
||||
"chunk_separator" => " ... ",
|
||||
"limit" => 400,
|
||||
"around" => 15
|
||||
);
|
||||
|
||||
|
||||
$cl = new SphinxClient ();
|
||||
$res = $cl->BuildExcerpts ( $docs, $index, $words, $opts );
|
||||
if ( !$res )
|
||||
{
|
||||
die ( "ERROR: " . $cl->GetLastError() . ".\n" );
|
||||
} else
|
||||
{
|
||||
foreach ( $res as $entry )
|
||||
{
|
||||
$n++;
|
||||
print "n=$n, res=$entry\n";
|
||||
}
|
||||
}
|
||||
|
||||
//
|
||||
// $Id: test2.php,v 1.4 2006/11/26 12:24:21 shodan Exp $
|
||||
//
|
||||
|
||||
?>
|
@ -1,108 +0,0 @@
|
||||
#!/usr/bin/php -q
|
||||
<?php
|
||||
|
||||
//
|
||||
// $Id: test.php,v 1.12 2006/11/26 12:24:21 shodan Exp $
|
||||
//
|
||||
|
||||
require ( "sphinxapi.php" );
|
||||
|
||||
//////////////////////
|
||||
// parse command line
|
||||
//////////////////////
|
||||
|
||||
// for very old PHP versions, like at my home test server
|
||||
if ( is_array($argv) && !isset($_SERVER["argv"]) )
|
||||
$_SERVER["argv"] = $argv;
|
||||
unset ( $_SERVER["argv"][0] );
|
||||
|
||||
// build query
|
||||
if ( !is_array($_SERVER["argv"]) || empty($_SERVER["argv"]) )
|
||||
die ( "usage: php -f test.php [--any] <word [word [word [...]]]> [--group <group>] [-p <port>] [-i <index>]\n" );
|
||||
|
||||
$args = array();
|
||||
foreach ( $_SERVER["argv"] as $arg )
|
||||
$args[] = $arg;
|
||||
|
||||
$q = "";
|
||||
$any = false;
|
||||
$groups = array();
|
||||
$port = 3312;
|
||||
$index = "*";
|
||||
for ( $i=0; $i<count($args); $i++ )
|
||||
{
|
||||
if ( $args[$i]=="--any" )
|
||||
{
|
||||
$any = true;
|
||||
} else if ( $args[$i]=="--group" )
|
||||
{
|
||||
$groups[] = (int)$args[++$i];
|
||||
} else if ( $args[$i]=="-p" )
|
||||
{
|
||||
$port = (int)$args[++$i];
|
||||
} else if ( $args[$i]=="-i" )
|
||||
{
|
||||
$index = $args[++$i];
|
||||
} else
|
||||
{
|
||||
$q .= $args[$i] . " ";
|
||||
}
|
||||
}
|
||||
|
||||
////////////
|
||||
// do query
|
||||
////////////
|
||||
|
||||
$cl = new SphinxClient ();
|
||||
$cl->SetServer ( "localhost", $port );
|
||||
$cl->SetWeights ( array ( 100, 1 ) );
|
||||
$cl->SetMatchMode ( $any ? SPH_MATCH_ANY : SPH_MATCH_ALL );
|
||||
if ( count($groups) )
|
||||
$cl->SetFilter ( "group_id", $groups );
|
||||
$res = $cl->Query ( $q, $index );
|
||||
|
||||
////////////////
|
||||
// print me out
|
||||
////////////////
|
||||
|
||||
if ( $res===false )
|
||||
{
|
||||
print "Query failed: " . $cl->GetLastError() . ".\n";
|
||||
|
||||
} else
|
||||
{
|
||||
if ( $cl->GetLastWarning() )
|
||||
print "WARNING: " . $cl->GetLastWarning() . "\n\n";
|
||||
|
||||
print "Query '$q' retrieved $res[total] of $res[total_found] matches in $res[time] sec.\n";
|
||||
print "Query stats:\n";
|
||||
if ( is_array($res["words"]) )
|
||||
foreach ( $res["words"] as $word => $info )
|
||||
print " '$word' found $info[hits] times in $info[docs] documents\n";
|
||||
print "\n";
|
||||
|
||||
if ( is_array($res["matches"]) )
|
||||
{
|
||||
$n = 1;
|
||||
print "Matches:\n";
|
||||
foreach ( $res["matches"] as $doc => $docinfo )
|
||||
{
|
||||
print "$n. doc_id=$doc, weight=$docinfo[weight]";
|
||||
foreach ( $res["attrs"] as $attrname => $attrtype )
|
||||
{
|
||||
$value = $docinfo["attrs"][$attrname];
|
||||
if ( $attrtype==SPH_ATTR_TIMESTAMP )
|
||||
$value = date ( "Y-m-d H:i:s", $value );
|
||||
print ", $attrname=$value";
|
||||
}
|
||||
print "\n";
|
||||
$n++;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//
|
||||
// $Id: test.php,v 1.12 2006/11/26 12:24:21 shodan Exp $
|
||||
//
|
||||
|
||||
?>
|
Loading…
x
Reference in New Issue
Block a user