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

+ gestion des max limits et des ranking !
This commit is contained in:
Damien LASSERRE 2011-09-26 15:59:35 +00:00
parent 4edb89a0ad
commit 50f4bc89ea
11 changed files with 485 additions and 171 deletions

View File

@ -43,7 +43,7 @@ class FormulairesController extends Zend_Controller_Action
$this->view->form = $act;
} else {
$sphinx = new SphinxClient();
$sphinx->SetServer('192.168.78.37', 3312);
$sphinx->SetServer('192.168.78.252', 3312);
$sphinx->SetConnectTimeout(1);
$sphinx->SetRankingMode(SPH_RANK_PROXIMITY_BM25);
$sphinx->SetArrayResult(true);
@ -86,7 +86,7 @@ class FormulairesController extends Zend_Controller_Action
public function serverstatutAction()
{
$sphinx = new SphinxClient();
$sphinx->SetServer('192.168.78.37', 3312);
$sphinx->SetServer('192.168.78.252', 3312);
if($sphinx->_Connect())
echo '<span style="color:green">Connected</span>';
else
@ -97,33 +97,57 @@ class FormulairesController extends Zend_Controller_Action
public function getsrvAction()
{
echo file_get_contents('http://192.168.78.37/query.log');
echo file_get_contents(APPLICATION_PATH.'/logs/query.log');
$this->_helper->layout()->disableLayout();
$this->_helper->viewRenderer->setNoRender(true);
}
public function entAction()
{
require_once ('Forms/FormSearchEnt.php');
$this->view->send = true;
if(!$this->getRequest()->isPost()) {
$ent = new Zend_Form();
$ent->setMethod('post');
foreach ($this->entChamps as $champ) {
$chp = $ent->createElement('text', $champ, array('value' => $champ))
->setRequired(true);
$ent->addElement($chp);
}
$ent->addElement("text", 'type', array('value'=>'ent'));
$ent = new Form_SearchEnt();
$this->view->form = $ent;
$this->render('form');
} else {
$this->_helper->layout()->disableLayout();
$sphinx = new SphinxClient();
$sphinx->SetServer('192.168.78.37', 3312);
$sphinx->SetServer('192.168.78.252', 3312);
$sphinx->SetConnectTimeout(1);
$sphinx->SetRankingMode(SPH_RANK_PROXIMITY_BM25);
$sphinx->SetArrayResult(true);
switch($this->getRequest()->getParam('SPH_RANK')) {
case 'SPH_RANK_PROXIMITY_BM25':
$sphinx->SetRankingMode(SPH_RANK_PROXIMITY_BM25);
break;
case 'SPH_RANK_BM25':
$sphinx->SetRankingMode(SPH_RANK_BM25);
break;
case 'SPH_RANK_NONE':
$sphinx->SetRankingMode(SPH_RANK_NONE);
break;
case 'SPH_RANK_WORDCOUNT':
$sphinx->SetRankingMode(SPH_RANK_WORDCOUNT);
break;
case 'SPH_RANK_PROXIMITY':
$sphinx->SetRankingMode(SPH_RANK_PROXIMITY);
break;
case 'SPH_RANK_MATCHANY':
$sphinx->SetRankingMode(SPH_RANK_MATCHANY);
break;
case 'SPH_MATCH_ANY':
$sphinx->SetRankingMode(SPH_MATCH_ANY);
break;
case 'SPH_RANK_FIELDMASK':
$sphinx->SetRankingMode(SPH_RANK_FIELDMASK);
break;
default:
$sphinx->SetRankingMode(SPH_RANK_PROXIMITY_BM25);
}
$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)
@ -140,14 +164,16 @@ class FormulairesController extends Zend_Controller_Action
$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);
$rechercheEnt->execute();
$this->view->isPost = $this->getRequest()->isPost();
$params = $this->getRequest()->getParams();
}
$this->render('form');
}
}

View File

@ -0,0 +1,60 @@
[21/09/2011] scores et decisions dddddddddd
[21/09/2011] scopre
[22/09/2011] scores et decisions
[22/09/2011] raisonSociale
[22/09/2011] raisonSociale
[22/09/2011] raisonSociale
[22/09/2011] raisonSociale
[22/09/2011] raisonSociale
[22/09/2011] raisonSociale
[22/09/2011] raisonSociale
[22/09/2011] raisonSociale
[22/09/2011] raisonSociale
[22/09/2011] raisonSociale
[22/09/2011] raisonSociale
[22/09/2011] raisonSociale
[22/09/2011] raisonSociale
[22/09/2011] raisonSociale
[22/09/2011] raisonSociale
[22/09/2011] raisonSociale
[22/09/2011] raisonSociale
[22/09/2011] raisonSociale
[22/09/2011] raisonSociale
[22/09/2011] raisonSociale
[22/09/2011] raisonSociale
[22/09/2011] raisonSociale
[22/09/2011] raisonSociale
[22/09/2011] raisonSociale
[22/09/2011] raisonSociale
[22/09/2011] raisonSociale
[22/09/2011] raisonSociale
[22/09/2011]
[22/09/2011]
[22/09/2011]
[22/09/2011] raisonSociale
[22/09/2011] raisonSociale
[22/09/2011] raisonSociale
[22/09/2011] raisonSociale
[22/09/2011] scores et decisions
[22/09/2011] scores et decisions
[22/09/2011] scores et decisions
[22/09/2011] scores et decisions
[22/09/2011] scores et decisions
[22/09/2011] scores et decisions
[22/09/2011] scores et decisions
[22/09/2011] scores et decisions
[22/09/2011] scores et decisions
[22/09/2011] scores et decisions
[22/09/2011] scores et decisions
[22/09/2011] scores decisions
[22/09/2011] scores decisions
[22/09/2011] scores decisions
[22/09/2011] scores decisions
[22/09/2011] scores decisions
[22/09/2011] scores decisions
[22/09/2011] scores decisions
[22/09/2011] scores decisions
[23/09/2011] score dekisions
[23/09/2011]
[23/09/2011] score dekisions

View File

@ -0,0 +1,55 @@
<?php
/**
* Séquances d'échapements pour le formulaires entreprise.
*
* S : RaisonSociale
* I : Siren/Siret
* N : Numero de rue
* R : Rue Type de voie
* D : Departement ou CodePostale
* L : Les trois derniers chiffre du codePoste
* V : Ville
* A : Code Ape
*
**/
$ordonnances = array('S', 'R', 'N', 'V', 'L', 'D', 'I');
$link = array(
'S' => array('max' => 1000, 'id' => array('10')),
'S.R' => array('max' => 1000, 'id' => array('11', '10')),
'S.N' => array('max' => 1000, 'id' => array('12', '10')),
'S.N.R' => array('max' => 1000, 'id' => array(array('13', '12', '11', '10'))),
'S.N.R.V' => array('max' => 1000, 'id' => array('17', '16', '15' ,'14' ,'13', '12', '11', '10')),
'S.V' => array('max' => 1000, 'id' => array('14', '10')),
'S.V.N' => array('max' => 1000, 'id' => array('15', '14', '12', '10')),
'S.V.R' => array('max' => 1000, 'id' => array('16', '14', '11', '10')),
'S.V.N.R' => array('max' => 1000, 'id' => array('17', '15', '14', '13', '12', '11', '10')),
'S.D' => array('max' => 1000, 'id' => array('18')),
'S.D.N' => array('max' => 1000, 'id' => array('19', '18', '12', '10')),
'S.D.R' => array('max' => 1000, 'id' => array('24', '18', '11', '10')),
'S.D.N.R' => array('max' => 1000, 'id' => array('25', '28', '19', '18', '12', '11', '10')),
'S.D.V' => array('max' => 1000, 'id' => array('20', '18', '14', '10')),
'S.D.V.R' => array('max' => 1000, 'id' => array('21', '20', '18', '14', '11', '10')),
'S.D.V.N' => array('max' => 1000, 'id' => array('22', '20', '18', '14', '12', '10')),
'S.D.V.N.R'=> array('max' => 1000, 'id' => array('23' ,'25', '24', '22', '20', '18', '14', '12', '11', '10')),
);
$sequence = array(
'10' => 'S',
'11' => 'S.R',
'12' => 'S.N',
'13' => 'S.N.R',
'14' => 'S.V',
'15' => 'S.V.N',
'16' => 'S.V.R',
'17' => 'S.V.N.R',
'18' => 'S.D',
'19' => 'S.D.N',
'20' => 'S.D.V ',
'21' => 'S.D.V.R',
'22' => 'S.D.V.N',
'23' => 'S.D.V.N.R',
'24' => 'S.D.R',
'25' => 'S.D.N.R',
);
?>

View File

@ -0,0 +1,18 @@
<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]<?php print_r($this->params);?></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>

View File

@ -1,95 +1,49 @@
<div style="color:black;float:left;">
<div style="float:left">
<fieldset style="background-image: url('/themes/default/images/stipe.png');border:1px dashed white;">
<legend style="font-size:13px;font-family:Verdana">Configurations</legend>
<button class="config" style="background-image:url('/themes/default/images/green.png');" name="default" value="true" >Defaut</button><br />
<button class="config" style="background-image:url('/themes/default/images/red.png');" name="basic" value="false" >Basique</button><br />
<button class="config" style="background-image:url('/themes/default/images/red.png');" name="full" value="false" >Full</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">Activez vos fonctions</legend>
<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 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>
<fieldset style="background-image: url('/themes/default/images/stipe.png');border:1px dashed white;">
<legend style="font-size:13px;font-family:Verdana">Autres...</legend>
<table>
<tr>
<td><span style="font-family:Verdana;font-size:10px;">WordSize Ignore</span></td>
<td>
<img class="moin" style="cursor: pointer" src="/themes/default/images/icone_moin.gif" title="MaxSizeWord">
<input readonly="true" value="3" type="text" id="MaxSizeWord" name="MaxSizeWord" style="width:30px;"/>
<img class="plus" style="cursor: pointer" src="/themes/default/images/icone_plus.gif" title="MaxSizeWord"><br />
</td>
</tr>
<tr>
<td><span style="font-family:Verdana;font-size:10px;">Quorum Size</span></td>
<td>
<img class="moin" title="Quorumsize" style="cursor: pointer" src="/themes/default/images/icone_moin.gif">
<input readonly="true" value="0" type="text" id="Quorumsize" name="Quorumsize" style="width:30px;"/>
<img class="plus" title="Quorumsize" 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>
<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="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;">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;"/>
<img class="plus" title="MaxResult" style="cursor: pointer" src="/themes/default/images/icone_plus.gif"><br />
</td>
</tr>
</table>
</fieldset>
</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:0px;">
<div style="float:left;width:80%">
<?php echo $this->form;?>
<?php if(!$this->isPost):?>
<div style="color:black;float:left;">
<div style="float:left">
<fieldset style="background-image: url('/themes/default/images/stipe.png');border:1px dashed white;">
<legend style="font-size:13px;font-family:Verdana">Configurations</legend>
<button id="default_val" class="config" style="background-image:url('/themes/default/images/red.png');" name="default" activated="true" >Defaut</button><br />
<button id="basic_val" class="config" style="background-image:url('/themes/default/images/red.png');" name="basic" activated="false" >Basique</button><br />
<button id="full_val" class="config" style="background-image:url('/themes/default/images/red.png');" name="full" activated="false" >Full</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">Activez vos fonctions</legend>
<button id="debugVal" class="params" style="background-image:url('/themes/default/images/red.png');" name="debug" activated="false" >Activer le debug</button><br />
<button id="sequanceVal" class="params" style="background-image:url('/themes/default/images/red.png');" name="sequance" activated="false" >Gestion des sequances</button><br />
<button id="quorumsVal" class="params" style="background-image:url('/themes/default/images/red.png');" name="quorums" activated="false" >Gestion des quorums</button><br />
<button id="proximitesVal" class="params" style="background-image:url('/themes/default/images/red.png');" name="proximites" activated="false" >Gestion de proximité</button><br />
<button id="weightVal" class="params" style="background-image:url('/themes/default/images/red.png');" name="weight" activated="false" >Gestion de poids</button><br />
<button id="actifVal" class="params" style="background-image:url('/themes/default/images/red.png');" name="actif" activated="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">Ranking modes</legend>
<button id="SPH_RANK_PROXIMITY_BM25_VAL" class="params" style="background-image:url('/themes/default/images/red.png');" name="SPH_RANK" value="SPH_RANK_PROXIMITY_BM25" activated="false" >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" value="SPH_RANK_BM25" activated="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" value="SPH_RANK_NONE" activated="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" value="SPH_RANK_WORDCOUNT" activated="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" value="SPH_RANK_PROXIMITY" activated="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" value="SPH_RANK_MATCHANY" activated="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" value="SPH_MATCH_ANY" activated="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" value="SPH_RANK_FIELDMASK" activated="false" >RANK_FIELDMASK</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">Sorting modes</legend>
<button id="SPH_SORT_RELEVANCE_VAL" class="params" style="background-image:url('/themes/default/images/red.png');" name="SPH_SORT" value="SPH_SORT_RELEVANCE" activated="false" >SORT_RELEVANCE</button><br />
<button id="SPH_SORT_ATTR_DESC_VAL" class="params" style="background-image:url('/themes/default/images/red.png');" name="SPH_SORT" value="SPH_SORT_ATTR_DESC" activated="false" >SORT_ATTR_DESC</button><br />
<button id="SPH_SORT_ATTR_ASC_VAL" class="params" style="background-image:url('/themes/default/images/red.png');" name="SPH_SORT" value="SPH_SORT_ATTR_ASC" activated="false" >SORT_ATTR_ASC</button><br />
<button id="SPH_SORT_TIME_SEGMENTS_VAL" class="params" style="background-image:url('/themes/default/images/red.png');" name="SPH_SORT" value="SPH_SORT_TIME_SEGMENTS" activated="false" >SORT_TIME_SEGMENTS</button><br />
<button id="SPH_SORT_EXTENDED_VAL" class="params" style="background-image:url('/themes/default/images/red.png');" name="SPH_SORT" value="SPH_SORT_EXTENDED" activated="false" >SORT_EXTENDED</button><br />
<button id="SPH_SORT_EXPR_VAL" class="params" style="background-image:url('/themes/default/images/red.png');" name="SPH_SORT" value="SPH_SORT_EXPR" activated="false" >SORT_EXPR</button><br />
</fieldset>
</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>
<?php endif;?>
<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:0px;">
<div style="float:left;width:100%">
<?php echo $this->form;?>
</div>
</div>
</div>

View File

@ -1,8 +1,42 @@
<ul>
<a href=""><li><button style="height:20px;">Indexer</button></li></a>
<a href=""><li><button style="height:20px;">Start - Stop</button></li></a>
<a href="http://sphinxphp/formulaires/act"><li><button>Formulaire actionnaires</button></li></a>
<a href="http://sphinxphp/formulaires/ent"><li><button>Formulaire entreprise</button></li></a>
<a href="http://sphinxphp/formulaires/dir"><li><button>Formulaire dirigeant</button></li></a>
<a href="http://sphinxphp/formulaires/histo"><li><button>Formulaire historique</button></li></a>
</ul>
<div>
<a href="http://sphinxphp/"><button style="margin-left:40px;width:206px;height:50px;margin-top:16px;">Formulaire entreprise</button></a>
</div>
<div style="margin-left:40px;width:206px;margin-top:5px;">
<fieldset style="background-image: url('/themes/default/images/stipe.png');border:1px dashed white;">
<legend style="font-size:13px;font-family:Verdana"></legend>
<table>
<tr>
<td><span style="font-family:Verdana;font-size:10px;">WordSize Ignore</span></td>
<td>
<img class="moin" style="cursor: pointer" src="/themes/default/images/icone_moin.gif" title="MaxSizeWord">
<input readonly="true" value="1" type="text" id="MaxSizeWord" name="MaxSizeWord" style="width:30px;"/>
<img class="plus" style="cursor: pointer" src="/themes/default/images/icone_plus.gif" title="MaxSizeWord"><br />
</td>
</tr>
<tr>
<td><span style="font-family:Verdana;font-size:10px;">Quorum Size</span></td>
<td>
<img class="moin" title="Quorumsize" style="cursor: pointer" src="/themes/default/images/icone_moin.gif">
<input readonly="true" value="0" type="text" id="Quorumsize" name="Quorumsize" style="width:30px;"/>
<img class="plus" title="Quorumsize" 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>
<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="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;">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;"/>
<img class="plus" title="MaxResult" style="cursor: pointer" src="/themes/default/images/icone_plus.gif"><br />
</td>
</tr>
</table>
</fieldset>
</div>

View File

@ -7,8 +7,7 @@ $matchMode = array('SPH_MATCH_ALL' => '<b>SPH_MATCH_ALL</b>, matches all query w
'SPH_MATCH_EXTENDED2' => '<b>SPH_MATCH_EXTENDED2</b>, matches query using the second version of the Extended matching mode.',
'SPH_MATCH_FULLSCAN' => '<b>SPH_MATCH_FULLSCAN</b>, matches query, forcibly using the "full scan" mode as below. NB, any query terms will be ignored, such that filters, filter-ranges and grouping will still be applied, but no text-matching.'
);?>
<div style="margin-left:40px;">
<center style="font-family:verdana;font-size:14px">Executer votre recherche</center>
<div style="margin-left:40px;margin-top: 0px;">
<table>
<?php foreach($matchMode as $name => $val):?>
<tr class="tooltip" title="<?php echo htmlentities($val)?>">
@ -17,6 +16,6 @@ $matchMode = array('SPH_MATCH_ALL' => '<b>SPH_MATCH_ALL</b>, matches all query w
<?php endforeach;?>
</table>
</div>
<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 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:252px;" id="log">
<div id="loaddiv"><img style="margin-left:40px;margin-top:70px;" src="/themes/default/images/ajax-loader.gif" /></div>
</div>

View File

@ -0,0 +1,23 @@
<?php
/*
* To change this template, choose Tools | Templates
* and open the template in the editor.
*/
class Form_SearchEnt extends Zend_Form
{
public function init()
{
$this->setName('ent');
$this->setMethod('post');
$this->setAction('formulaires/ent');
$this->addElement('text', 'siren', array('value' => 'siren', 'class' => 'formText'));
$this->addElement('text', 'raisonSociale', array('value' => 'raisonSociale', 'class' => 'formText'));
$this->addElement('text', 'numeroVoie', array('value' => 'numeroVoie', 'class' => 'formText'));
$this->addElement('text', 'Voie', array('value' => 'Voie', 'class' => 'formText'));
$this->addElement('text', 'cpVille', array('value' => 'cpVille', 'class' => 'formText'));
$this->addElement('text', 'naf', array('value' => 'naf', 'class' => 'formText'));
$this->addElement("text", 'type', array('value'=>'ent', 'class' => 'formText'));
}
}
?>

View File

@ -20,10 +20,7 @@ Class ent extends rechercheFonc
/** Séquance d'échappement. **/
protected $form2crit = array('siren' => 'I',
'telFax' => 'T',
'raisonSociale' => 'S',
'enseigne' => 'E',
'prenom' => 'P',
'departement' => 'D',
'localite' => 'L',
'cpVille' => 'V',
@ -33,9 +30,12 @@ Class ent extends rechercheFonc
);
/** Liste des filtres sphinx **/
protected $filters = array('siren' => 'siret',
'nic' => '',
'siege' => '',
'adr_num' => 'numeroVoie',
'adr_cp' => 'cpVille',
'adr_dep' => 'cpVille',
'actif' => 'actif'
);
protected $mode;
protected $deb;
@ -103,6 +103,7 @@ Class ent extends rechercheFonc
'Erreure :' => 'Le formulaire est Vide !')
);
$this->filtreCaracteresSpeciaux();
$this->sphinx->SetSortMode($this->setSortMode($this->formR['SPH_SORT']), "@weight rang");
switch($this->formR['SPH_MATCH']) {
case 'SPH_MATCH_ALL':
$this->sphinx->SetMatchMode(SPH_MATCH_ALL);
@ -133,8 +134,15 @@ Class ent extends rechercheFonc
return;
case 'SPH_MATCH_FULLSCAN':
return;
$this->getDebugRequette();
}
/** @todo a prévoir !
* vopir pour la verification du mode de sortie de sphinx.
* Prévoir un input de selection avec les différents modes de sortie.
* $this->sphinx->SetSortMode(SPH_SORT_EXTENDED, "@adr_num desc");
*/
$this->getDebugRequette();
if($resSphinx['matches'] > 0) {
$this->setTime($resSphinx['time']);
$this->getResultSphinx($resSphinx);
@ -143,31 +151,41 @@ Class ent extends rechercheFonc
/***************************************************************************************************************/
/** Partie Requette **/
public function SPH_MATCH_($type, $option = null)
public function SPH_MATCH_($type)
{
$requete = '';
$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].' ';
}
$requete .= $option;
foreach($this->filters as $filter => $form) {
if(!empty($this->formR[$form])) {
if($filter == 'adr_cp') {
if(strlen($this->formR[$form]) == 5)
$this->sphinx->setFilter($filter, array($this->formR[$form]));
} else if ($filter == 'adr_dep') {
$this->sphinx->setFilter($filter, array(substr($this->formR[$form],0 , 2)));
}
else
$this->sphinx->setFilter($filter, array($this->formR[$form]));
$html = '';
require_once APPLICATION_PATH.'/sequances/sequence.php';
$i = 0;
$valeur = explode(':', $this->detectedSequance());
$valeur = trim($valeur[0]);
foreach($link[$valeur]['id'] as $seqId) {
$html .= '<br /><b>Séquence :</b> '.$sequence[$link[$valeur]['id'][$i]];
$request = $this->constructQuerySequance($sequence[$link[$valeur]['id'][$i]], $type);
$result = $this->sphinx->Query($request, $this->index);
if($result['total'] > 0 and $link[$valeur]['max'] > $result['total']) {
$html .= ' - '.$result['total'].'/'.$result['total_found']. ' Found !';
break;
}
$html .= ' - <sub><i>0 founds</i></sub> - <b>'.$request.'</b><br />';
$i++;
}
if($this->actif)
$this->sphinx->setFilter('actif', array(1));
return ($this->sphinx->Query($requete, $this->index));
/* decremente le quorum en dernier recour ou ont supprime des mots de la raison sociale */
/*$array = explode(' ', $this->formR['raisonSociale']);
if($this->Quorumsize > 0 and $result['total'] == 0 and count($array) > 1) {
$this->Quorumsize--;
$this->SPH_MATCH_ ($type);
} else if($result['total'] == 0 and $this->Quorumsize == 0 and count($array) > 1) {
//$this->formR['raisonSociale'] = $this->deleteWord();
if(count($array) > 0) {
unset($array[count($array)]);
$this->formR['raisonSociale'] = implode(' ', $array);
}
$this->Quorumsize = count(explode(' ', $this->formR['raisonSociale']));
$this->SPH_MATCH_ ($type);
}*/
$this->printInformations($html);
return ($result);
}
public function formatRaisonSociale($rs)
@ -201,11 +219,75 @@ Class ent extends rechercheFonc
$sequance = "";
foreach($this->formR as $name => $form) {
if($name != 'SPH_MATCH') {
$sequance .= $this->form2crit[$name];
$sequance .= '.'.$this->form2crit[$name];
$values .= $name.', ';
}
}
return ($sequance.' : '.$values);
return (substr($sequance,1).' : '.$values);
}
protected function readFileSequance($file)
{
$handle = fopen($file, 'r');
if($handle) {
while($data = fgetcsv($handle, 1000, ',') !== FALSE) {
if($data == $this->detectedSequance()) {
$this->constructQuerySequance($data);
}
}
}
}
protected function constructQuerySequance($sequances, $type)
{
$this->sphinx->ResetFilters();
$request = $request .= (($type=='SPH_MATCH_EXTENDED' or $type=='SPH_MATCH_EXTENDED2')?'@nom ':'').'"';
$adresse = '@adresse "';
foreach($this->form2crit as $name => $crit) {
$diff = explode('.', $sequances);
if(in_array($crit, $diff)) {
if($name == 'raisonSociale') {
$request .= $this->formatRaisonSociale($this->formR[$name]);
}
else if($name == 'cpVille') {
if(is_numeric($this->formR[$name]))
{
if(strlen($this->formR[$name]) == 2) {
$this->sphinx->setFilter('adr_dep', array($this->formR[$name]));
} else if (strlen($this->formR[$name]) == 5) {
$this->sphinx->setFilter('adr_dep', array(substr($this->formR[$name],0,2)));
$this->sphinx->setFilter('adr_cp', array(substr($this->formR[$name])));
}
} else {
$adresse .= $this->formR[$name];
}
}
else if($name == 'Voie') {
$adresse .= $this->formR[$name];
}
else if ($name == 'siren') {
if(strlen($this->formR[$name]) == 14) {
$this->sphinx->setFilter('siren', array(substr($this->formR[$name], 0, 9)));
$this->sphinx->setfilter('nic', array(substr($this->formR[$name], 9)));
} else if (strlen($this->fomrR[$name]) == 9) {
$this->sphinx->setFilter('siren', array($this->formR[$name]));
}
}
else if($name == 'numeroVoie') {
$this->sphinx->setFilter('adr_num', array($this->formR[$name]));
}
else if ($this->actif) {
$this->sphinx->setFilter('actif', array(1));
} else {
$request .= $this->formR[$name].' ';
}
}
}
$request .= '"'. (($this->ProximiteSize > 0)?'~'.$this->ProximiteSize:'').' '.(($this->Quorumsize > 0)?'/'.$this->Quorumsize:'');
if($adresse != '@adresse "')
$request = $request .' '.$adresse.'"';
return ($request);
}
@ -223,6 +305,7 @@ Class ent extends rechercheFonc
$sql .= ' OR ';
$i++;
}
$sql .= " ORDER BY rang DESC";
$db = $this->databaseJO();
$result = $db->query($sql);
@ -254,6 +337,8 @@ Class ent extends rechercheFonc
$html .= '<li>'.$filter.' => '.$this->formR[$form].'</li>';
}
}
if($this->actif)
$html .= '<li>Actif => true</li>';
$html .= '</ol>';
$this->printInformations($html);
}
@ -295,7 +380,26 @@ Class ent extends rechercheFonc
}
/***************************************************************************************************************/
/** Partie Setters **/
public function setSortMode($mode) {
switch($mode) {
case 'SPH_SORT_RELEVANCE':
return (SPH_SORT_RELEVANCE);
case 'SPH_SORT_ATTR_DESC':
return (SPH_SORT_ATTR_DESC);
case 'SPH_SORT_ATTR_ASC':
return (SPH_SORT_ATTR_ASC);
case 'SPH_SORT_TIME_SEGMENTS':
return (SPH_SORT_TIME_SEGMENTS);
case 'SPH_SORT_EXTENDED':
return (SPH_SORT_EXTENDED);
case 'SPH_SORT_EXPR':
return (SPH_SORT_EXPR);
default:
return (SPH_SORT_RELEVANCE);
}
}
public function setForm($form) {
$this->formR = $form;}

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.1 KiB

View File

@ -30,22 +30,28 @@ $(document).ready( 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 debug = $('#debugVal').attr('activated');
var sequances = $('#sequanceVal').attr('activated');
var quorums = $('#quorumsVal').attr('activated');
var proximites = $('#proximitesVal').attr('activated');
var weight = $('#weightVal').attr('activated');
var actif = $('#actifVal').attr('activated');
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 tabs = ["SPH_SORT_RELEVANCE_VAL", "SPH_SORT_ATTR_DESC_VAL", "SPH_SORT_ATTR_ASC_VAL", "SPH_SORT_TIME_SEGMENTS_VAL", "SPH_SORT_EXTENDED_VAL", "SPH_SORT_EXPR_VAL"];
for (i = 0; i < tabs.length; i++) {
if($("#"+tabs[i]).attr('activated') == 'true') {
var SPH_SORT = tabs[i];
break;
}
}
var tab = ["SPH_RANK_PROXIMITY_BM25_VAL", "SPH_RANK_BM25_VAL", "", "SPH_RANK_NONE_VAL", "SPH_RANK_WORDCOUNT_VAL", "SPH_RANK_PROXIMITY_VAL", "SPH_RANK_MATCHANY_VAL", "SPH_MATCH_ANY_VAL", "SPH_RANK_FIELDMASK_VAL"];
for (i = 0; i < tab.length; i++) {
if($("#"+tab[i]).attr('activated') == 'true') {
var SPH_RANK = tab[i];
break;
}
}
var WordSize = $('#MaxSizeWord').attr('value');
var QuorumSize = $('#Quorumsize').attr('value');
var ProximiteSize = $('#ProximiteSize').attr('value');
@ -53,13 +59,14 @@ $(document).ready( function()
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 + '&SPH_RANK='+SPH_RANK.replace("_VAL", "");
data = data + '&SPH_SORT='+SPH_SORT.replace("_VAL", "");
data = data + '&WordSize='+WordSize+'&QuorumSize='+QuorumSize+'&ProximiteSize='+ProximiteSize+'&MaxResult='+MaxResult+'&IsPost=true'
alert(data);
$.post("formulaires/ent", data, function(data){
$("form").html(data);
});
$('#filtre').css('display', 'block');
});
$('input[type=text]').focus(function(){
@ -68,17 +75,49 @@ $(document).ready( function()
$('#reset').click(function(){
$('input[type=text]').attr('value', '');
})
});
$('.config').click(function(){
var attrib = $(this).attr('name');
if($(this).attr('activated') == 'true') {
if(attrib == 'default') {
$('#quorumsVal').click();
$('#debugVal').click();
$('#proximitesVal').click();
$('#SPH_SORT_EXTENDED_VAL').click();
$('#SPH_RANK_PROXIMITY_BM25_VAL').click();
} else if (attrib == 'basic') {
$('#quorumsVal').click();
}
} else {
if(attrib == 'default') {
$('#quorumsVal').attr('activated', 'false');
$('#debugVal').attr('activated', 'false');
$('#proximitesVal').attr('activated', 'false');
$('#SPH_SORT_EXTENDED_VAL').attr('activated', 'false');
$('#SPH_RANK_PROXIMITY_BM25_VAL').attr('activated', 'false');
$('#SPH_RANK_PROXIMITY_BM25_VAL').click();
$('#SPH_SORT_EXTENDED_VAL').click();
$('#quorumsVal').click();
$('#debugVal').click();
$('#proximitesVal').click();
} else if (attrib == 'basic') {
$('#quorumsVal').click();
}
}
});
$('.params').click(function(){
var bool = $(this).attr('value');
var bool = $(this).attr('activated');
if(bool == 'true') {
$(this).attr('value', 'false');
$(this).attr('activated', 'false');
$(this).css('background-image', "url('/themes/default/images/red.png')");
$("#"+$(this).attr('name')).css('display', 'none');
} else {
$(this).attr('value', 'true');
$(this).attr('activated', 'true');
$(this).css('background-image', "url('/themes/default/images/green.png')");
$("#"+$(this).attr('name')).css('display', 'block');
}
@ -135,4 +174,6 @@ $(document).ready( function()
$('#statut').load('/formulaires/serverstatut').fadeOut('slow');
$('#statut').load('/formulaires/serverstatut').fadeIn('slow');
}, 5000); // refresh every 10000 milliseconds
$('#default_val').click();
});