Mise a jours de Sphinx interface de recherche avec implementation des nouvelles fonctionnalitées de sphinx.

This commit is contained in:
Damien LASSERRE 2011-09-20 15:51:34 +00:00
parent 5779f4a40f
commit 4edb89a0ad
13 changed files with 216 additions and 44 deletions

View File

@ -83,6 +83,25 @@ class FormulairesController extends Zend_Controller_Action
$this->render('form');
}
public function serverstatutAction()
{
$sphinx = new SphinxClient();
$sphinx->SetServer('192.168.78.37', 3312);
if($sphinx->_Connect())
echo '<span style="color:green">Connected</span>';
else
echo '<span style="color:red">Disconnected</span>';
$this->_helper->layout()->disableLayout();
$this->_helper->viewRenderer->setNoRender(true);
}
public function getsrvAction()
{
echo file_get_contents('http://192.168.78.37/query.log');
$this->_helper->layout()->disableLayout();
$this->_helper->viewRenderer->setNoRender(true);
}
public function entAction()
{
$this->view->send = true;
@ -104,17 +123,29 @@ class FormulairesController extends Zend_Controller_Action
$sphinx->SetConnectTimeout(1);
$sphinx->SetRankingMode(SPH_RANK_PROXIMITY_BM25);
$sphinx->SetArrayResult(true);
$rechercheFonc = new ent($this->getRequest()->getParam('SPH_MATCH'), $sphinx, $this->getRequest()->getParams(), 1000);
$rechercheFonc->setIndex('ent');
$rechercheFonc->setForm($this->getRequest()->getParams());
$rechercheFonc->setSphinx($sphinx);
echo $rechercheFonc->execute();
$rechercheEnt = new ent($this->getRequest()->getParam('SPH_MATCH'), $sphinx, $this->getRequest()->getParams(), 1000);
if($this->getRequest()->getParam('debug') == 'true')
$rechercheEnt->setDebug();
if($this->getRequest()->getParam('QuorumSize') > 0)
$rechercheEnt->setQuorumsize($this->getRequest()->getParam('QuorumSize'));
if($this->getRequest()->getParam('proximites') > 0)
$rechercheEnt->setProximiteSize ($this->getRequest()->getParam('proximites'));
if($this->getRequest()->getParam('sequances'))
$rechercheEnt->setSequance();
if($this->getRequest()->getParam('poids'))
$rechercheEnt->setPoids();
if($this->getRequest()->getParam('actif') == 'true')
$rechercheEnt->setActif();
if($this->getRequest()->getParam('WordSize') > 0)
$rechercheEnt->setMaxSizeWord ($this->getRequest()->getParam('WordSize'));
if($this->getRequest()->getParam('MaxResult') != 1000 and $this->getRequest()->getParam('MaxResult') > 0)
$rechercheEnt->setMaxResults ($this->getRequest()->getParam('MaxResult'));
$rechercheEnt->setIndex('ent');
$rechercheEnt->setForm($this->getRequest()->getParams());
$rechercheEnt->setSphinx($sphinx);
echo $rechercheEnt->execute();
$this->_helper->layout()->disableLayout();
$this->_helper->viewRenderer->setNoRender(true);
if($sphinx->IsConnectError())
$this->view->server = true;
else
$this->view->server = false;
}
}

View File

@ -8,23 +8,23 @@
</fieldset>
<fieldset style="background-image: url('/themes/default/images/stipe.png');border:1px dashed white;">
<legend style="font-size:13px;font-family:Verdana">Activez vos fonctions</legend>
<button class="params" style="background-image:url('/themes/default/images/green.png');" name="debug" value="true" >Activer le debug</button><br />
<button class="params" style="background-image:url('/themes/default/images/red.png');" name="sequance" value="false" >Gestion des sequances</button><br />
<button class="params" style="background-image:url('/themes/default/images/red.png');" name="quorums" value="false" >Gestion des quorums</button><br />
<button class="params" style="background-image:url('/themes/default/images/red.png');" name="proximites" value="false" >Gestion de proximité</button><br />
<button class="params" style="background-image:url('/themes/default/images/red.png');" name="weight" value="false" >Gestion de poids</button><br />
<button class="params" style="background-image:url('/themes/default/images/red.png');" name="actif" value="false" >Etablissement Actif</button><br />
<button id="debugVal" class="params" style="background-image:url('/themes/default/images/green.png');" name="debug" value="true" >Activer le debug</button><br />
<button id="sequanceVal" class="params" style="background-image:url('/themes/default/images/red.png');" name="sequance" value="false" >Gestion des sequances</button><br />
<button id="quorumsVal" class="params" style="background-image:url('/themes/default/images/red.png');" name="quorums" value="false" >Gestion des quorums</button><br />
<button id="proximitesVal" class="params" style="background-image:url('/themes/default/images/red.png');" name="proximites" value="false" >Gestion de proximité</button><br />
<button id="weightVal" class="params" style="background-image:url('/themes/default/images/red.png');" name="weight" value="false" >Gestion de poids</button><br />
<button id="actifVal" class="params" style="background-image:url('/themes/default/images/red.png');" name="actif" value="false" >Etablissement Actif</button><br />
</fieldset>
<fieldset style="background-image: url('/themes/default/images/stipe.png');border:1px dashed white;">
<legend style="font-size:13px;font-family:Verdana">Options Sphinx</legend>
<button class="params" style="background-image:url('/themes/default/images/green.png');" name="SPH_RANK_PROXIMITY_BM25" value="true" >RANK_PROXIMITY_BM25</button><br />
<button class="params" style="background-image:url('/themes/default/images/red.png');" name="SPH_RANK_BM25" value="false" >RANK_BM25</button><br />
<button class="params" style="background-image:url('/themes/default/images/red.png');" name="SPH_RANK_NONE" value="false" >RANK_NONE</button><br />
<button class="params" style="background-image:url('/themes/default/images/red.png');" name="SPH_RANK_WORDCOUNT" value="false" >RANK_WORDCOUNT</button><br />
<button class="params" style="background-image:url('/themes/default/images/red.png');" name="SPH_RANK_PROXIMITY" value="false" >RANK_PROXIMITY</button><br />
<button class="params" style="background-image:url('/themes/default/images/red.png');" name="SPH_RANK_MATCHANY" value="false" >RANK_MATCHANY</button><br />
<button class="params" style="background-image:url('/themes/default/images/red.png');" name="SPH_MATCH_ANY" value="false" >MATCH_ANY</button><br />
<button class="params" style="background-image:url('/themes/default/images/red.png');" name="SPH_RANK_FIELDMASK" value="false" >RANK_FIELDMASK</button><br />
<button id="SPH_RANK_PROXIMITY_BM25_VAL" class="params" style="background-image:url('/themes/default/images/green.png');" name="SPH_RANK_PROXIMITY_BM25" value="true" >RANK_PROXIMITY_BM25</button><br />
<button id="SPH_RANK_BM25_VAL" class="params" style="background-image:url('/themes/default/images/red.png');" name="SPH_RANK_BM25" value="false" >RANK_BM25</button><br />
<button id="SPH_RANK_NONE_VAL" class="params" style="background-image:url('/themes/default/images/red.png');" name="SPH_RANK_NONE" value="false" >RANK_NONE</button><br />
<button id="SPH_RANK_WORDCOUNT_VAL" class="params" style="background-image:url('/themes/default/images/red.png');" name="SPH_RANK_WORDCOUNT" value="false" >RANK_WORDCOUNT</button><br />
<button id="SPH_RANK_PROXIMITY_VAL" class="params" style="background-image:url('/themes/default/images/red.png');" name="SPH_RANK_PROXIMITY" value="false" >RANK_PROXIMITY</button><br />
<button id="SPH_RANK_MATCHANY_VAL" class="params" style="background-image:url('/themes/default/images/red.png');" name="SPH_RANK_MATCHANY" value="false" >RANK_MATCHANY</button><br />
<button id="SPH_MATCH_ANY_VAL" class="params" style="background-image:url('/themes/default/images/red.png');" name="SPH_MATCH_ANY" value="false" >MATCH_ANY</button><br />
<button id="SPH_RANK_FIELDMASK_VAL" class="params" style="background-image:url('/themes/default/images/red.png');" name="SPH_RANK_FIELDMASK" value="false" >RANK_FIELDMASK</button><br />
</fieldset>
</div>
<div>
@ -51,12 +51,12 @@
<td><span style="font-family:Verdana;font-size:10px;">Proximité Size</span></td>
<td>
<img class="moin" title="Proximite" style="cursor: pointer" src="/themes/default/images/icone_moin.gif">
<input readonly="true" value="0" type="text" id="Proximite" name="Proximite" style="width:30px;"/>
<input readonly="true" value="0" type="text" id="Proximite" name="ProximiteSize" style="width:30px;"/>
<img class="plus" title="Proximite" style="cursor: pointer" src="/themes/default/images/icone_plus.gif"><br />
</td>
</tr>
<tr>
<td><span style="font-family:Verdana;font-size:10px;">Proximité Size</span></td>
<td><span style="font-family:Verdana;font-size:10px;">Max Results</span></td>
<td>
<img class="moin" title="MaxResult" style="cursor: pointer" src="/themes/default/images/icone_moin.gif">
<input readonly="true" value="1000" type="text" id="MaxResult" name="MaxResult" style="width:30px;"/>
@ -68,7 +68,28 @@
</div>
</div>
<div style="background-image: url('/themes/default/images/stipe.png');margin-top:6px;margin-left:10px;width:84%;height:100%;float:left;border:1px dashed white;">
<div style="text-align:center;padding-top:50px;">
<?php echo $this->form;?>
<div style="text-align:center;padding-top:0px;">
<div style="float:left;width:80%">
<?php echo $this->form;?>
</div>
<div id="filtre" style="padding:5px;text-align: left;background-image: url('/themes/default/images/information.png');color:black;font-family:Verdana;font-size:12px;display:none;border: 1px dashed white;float:left;width:19%;margin-top:10px">
<b style="font-size:14px;">Filtres activés</b><br />
<ul style="list-style-image: url('/themes/default/images/puce.gif');">
<li>Adr Numero <b>[adr_num]</b></li>
<li>Adr Rue <b>[adr_rue]</b></li>
<li>Adr CP <b>[adr_cp]</b></li>
<li>Adr Dept <b>[adr_dept]</b></li>
<li>Adr Ville <b>[adr_ville]</b></li>
</ul>
<br />
<b style="font-size:14px;">Options activées</b><br />
<ul style="list-style-image: url('/themes/default/images/boxR.png');">
<li>Le Debugging</li>
<li>Le Séquancing <b>(17)</b></li>
<li>Les Quorums <b>(/2)</b></li>
<li>La Proximites <b>~</b></li>
<li>Gestion de poids</li>
</ul>
</div>
</div>
</div>

View File

@ -0,0 +1,24 @@
<table style="background-color:#f7f7fc;font-family:Verdana;font-size:10px;">
<tr>
<td align="left"><b>Ip Server : </b></td>
<td align="left"><?php echo $this->ip;?></td>
</tr>
<tr>
<td align="left"><b>Port : </b></td>
<td align="left"><?php echo $this->port;?></td>
</tr>
<tr>
<td align="left"><b>Status : </b></td>
<td align="left">
<?php if(($this->server = true)):?>
<span style="color:green">Connected</span>
<?php else : ?>
<span style="color:red">Disconnected</span>
<?php endif;?>
</td>
</tr>
<tr>
<td align="left"><b>Version :</b></td>
<td>0.9.9</td>
</tr>
</table>

View File

@ -11,12 +11,8 @@
</tr>
<tr>
<td align="left"><b>Status : </b></td>
<td align="left">
<?php if(($this->server = true)):?>
<span style="color:green">Connected</span>
<?php else : ?>
<span style="color:red">Disconnected</span>
<?php endif;?>
<td id="statut" align="left">
</td>
</tr>
<tr>

View File

@ -17,8 +17,6 @@ $matchMode = array('SPH_MATCH_ALL' => '<b>SPH_MATCH_ALL</b>, matches all query w
<?php endforeach;?>
</table>
</div>
<br />
<center style="font-family:verdana;font-size:14px">Les logs en directes</center>
<div style="background-color:#fffdd6;overflow: auto;font-family:Verdana;font-size:11px;padding:5px;margin:5px 0px 40px 40px;border:1px solid black;height:115px;" id="log">
<?php echo file_get_contents('http://192.168.78.37/searchd.log');?>
<div id="scroll" style="background-image:url('/themes/default/images/box.png');overflow: auto;overflow: hidden;font-family:Verdana;font-size:11px;padding:5px;margin:5px 0px 40px 40px;border:1px dashed silver;height:152px;" id="log">
<div id="loaddiv"><img style="margin-left:50px;margin-top:10px;" src="/themes/default/images/ajax-loader.gif" /></div>
</div>

View File

@ -42,7 +42,17 @@ Class ent extends rechercheFonc
protected $nbRep;
protected $max;
protected $total_time;
protected $quorum;
protected $sequances;
protected $proximites;
protected $poids;
protected $actif;
protected $maxSizeWord;
protected $Quorumsize;
protected $ProximiteSize;
protected $MaxResult;
/**
*
@ -56,11 +66,19 @@ Class ent extends rechercheFonc
*/
public function __construct($mode, $deb, $nbRep, $max)
{
$this->mode = $mode;
$this->mode = $mode;
$this->deb = $deb;
$this->nbRep = $nbRep;
$this->max = $max;
$this->total_time = 0;
$this->quorum = false;
$this->sequances = false;
$this->proximites = false;
$this->poids = false;
$this->actif = false;
$this->MaxResult = 1000;
}
public function search()
@ -69,6 +87,8 @@ Class ent extends rechercheFonc
$quorumActif = false;
$quorum = array();
$array = array();
$this->sphinx->SetLimits(intval(0), $this->MaxResult, $this->MaxResult);
foreach($this->formR as $name => $form) {
if(array_key_exists($name, $this->form2crit) and !empty($this->formR[$name]))
@ -126,7 +146,8 @@ Class ent extends rechercheFonc
public function SPH_MATCH_($type, $option = null)
{
$requete = '';
$requete .= '@nom "'.$this->formR['raisonSociale'].'"';
$requete .= (($type=='SPH_MATCH_EXTENDED' or $type=='SPH_MATCH_EXTENDED2')?'@nom':''). '"'.$this->formatRaisonSociale($this->formR['raisonSociale']).
'" '.(($this->ProximiteSize > 0)?'~'.$this->ProximiteSize:'').' '.(($this->Quorumsize > 0)?'/'.$this->Quorumsize:'');
foreach($this->Crtiteres as $crit => $attr) {
if(!empty($this->formR[$attr]))
$requete .= ''.$attr.' '.$this->formR[$crit].' ';
@ -144,6 +165,8 @@ Class ent extends rechercheFonc
$this->sphinx->setFilter($filter, array($this->formR[$form]));
}
}
if($this->actif)
$this->sphinx->setFilter('actif', array(1));
return ($this->sphinx->Query($requete, $this->index));
}
@ -203,7 +226,7 @@ Class ent extends rechercheFonc
$db = $this->databaseJO();
$result = $db->query($sql);
$html = '<b>Resultat de la recherche :</b><br /><ol>';
$html .= '<b>Resultat de la recherche :</b><br /><ol>';
while($row = mysqli_fetch_assoc($result))
$html .= '<li><b>'.$row["raisonSociale"].'</b> '.$row['adr_cp'].' '.$row['adr_num'].' '.$row['adr_typeVoie'].' '.$row['adr_libVoie'].' '.$row['adr_ville'].'</li>';
$html .= '</ol>';
@ -264,9 +287,11 @@ Class ent extends rechercheFonc
protected function printInformations($informations)
{
echo '<div style="text-align:left;margin:5px;background-image: url(/themes/default/images/stipe.png);font-size:13px;font-family:Verdana;margin-top:10px;padding:5px;color:black;background-color:black;border:1px dashed white;">';
echo $informations;
echo '</div>';
if($this->debug) {
echo '<div style="text-align:left;margin:5px;background-image: url(/themes/default/images/information.png);font-size:13px;font-family:Verdana;margin-top:10px;padding:5px;color:black;background-color:black;border:1px dashed white;">';
echo $informations;
echo '</div>';
}
}
/***************************************************************************************************************/
/** Partie Setters **/
@ -287,6 +312,42 @@ Class ent extends rechercheFonc
public function setMaxSizeWord($size) {
$this->maxSizeWord = $size;
}
public function setSequance($bool = true) {
$this->sequances = $bool;
}
public function setQuorums($bool = true) {
$this->quorum = $bool;
}
public function setProximotes($bool = true) {
$this->proximites = $bool;
}
public function setPoids($bool = true) {
$this->poids = $bool;
}
public function setActif($bool = true) {
$this->actif = $bool;
}
public function setQuorumsize($size) {
$this->Quorumsize = $size;
}
public function setProximiteSize($size) {
$this->ProximiteSize = $size;
}
public function setMaxResults($max) {
$this->MaxResult = $max;
}
public function setDebug($bool = true) {
$this->debug = $bool;
}
/***************************************************************************************************************/
}

Binary file not shown.

After

Width:  |  Height:  |  Size: 8.0 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 107 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 529 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 103 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 143 B

View File

@ -29,10 +29,37 @@ $(document).ready( function()
$(".SPH_MATCH").click(function(){
$('#loader').css('display:block');
var data = $("form").serialize();
var debug = $('#debugVal').attr('value');
var sequances = $('#sequanceVal').attr('value');
var quorums = $('#quorumsVal').attr('value');
var proximites = $('#proximitesVal').attr('value');
var weight = $('#weightVal').attr('value');
var actif = $('#actifVal').attr('value');
var SPH_RANK_PROXIMITY_BM25 = $('#SPH_RANK_PROXIMITY_BM25_VAL').attr('value');
var SPH_RANK_BM25 = $('#SPH_RANK_BM25_VAL').attr('value');
var SPH_RANK_NONE = $('#SPH_RANK_NONE_VAL').attr('value');
var SPH_RANK_WORDCOUNT = $('#SPH_RANK_WORDCOUNT_VAL').attr('value');
var SPH_RANK_PROXIMITY = $('#SPH_RANK_PROXIMITY_VAL').attr('value');
var SPH_RANK_MATCHANY = $('#SPH_RANK_MATCHANY_VAL').attr('value');
var SPH_MATCH_ANY = $('#SPH_MATCH_ANY_VAL').attr('value');
var SPH_RANK_FIELDMASK = $('#SPH_RANK_FIELDMASK_VAL').attr('value');
var WordSize = $('#MaxSizeWord').attr('value');
var QuorumSize = $('#Quorumsize').attr('value');
var ProximiteSize = $('#ProximiteSize').attr('value');
var MaxResult = $('#MaxResult').attr('value');
data = data + '&SPH_MATCH='+$(this).attr('value');
data = data + '&debug='+debug+'&sequances='+sequances+'&quorums='+quorums+'&proximites='+proximites+'&weight='+weight+'&actif='+actif;
data = data + '&SPH_RANK_PROXIMITY_BM25='+SPH_RANK_PROXIMITY_BM25+'&SPH_RANK_BM25='+SPH_RANK_BM25+'&SPH_RANK_NONE='+SPH_RANK_NONE+'&SPH_RANK_WORDCOUNT='+
SPH_RANK_WORDCOUNT+'&SPH_RANK_PROXIMITY='+SPH_RANK_PROXIMITY+'&SPH_RANK_MATCHANY='+SPH_RANK_MATCHANY+'&SPH_MATCH_ANY='+SPH_MATCH_ANY+'&SPH_RANK_FIELDMASK='+SPH_RANK_FIELDMASK;
data = data + '&WordSize='+WordSize+'&QuorumSize='+QuorumSize+'&ProximiteSize='+ProximiteSize+'&MaxResult='+MaxResult+'&IsPost=true'
$.post("formulaires/ent", data, function(data){
$("form").html(data);
});
$('#filtre').css('display', 'block');
});
$('input[type=text]').focus(function(){
@ -94,4 +121,18 @@ $(document).ready( function()
$("#"+$(this).attr('title')).attr('value', resultat);
}
});
var auto_refresh = setInterval(
function ()
{
$('#loaddiv').load('/formulaires/getsrv').fadeIn('slow');
$('#scroll').scrollTop(9999999999);
}, 4000); // refresh every 10000 milliseconds
var auto_refresh2 = setInterval(
function ()
{
$('#statut').load('/formulaires/serverstatut').fadeOut('slow');
$('#statut').load('/formulaires/serverstatut').fadeIn('slow');
}, 5000); // refresh every 10000 milliseconds
});

View File

@ -100,7 +100,7 @@ div .debug pre {
float:left;
margin-top:17px;
margin-left:20px;
height:630px;
height:640px;
padding:5px;
overflow: auto;
background-color:#f7f7fc;