Subversion Repositories Applications.papyrus

Compare Revisions

Ignore whitespace Rev 2126 → Rev 2127

/trunk/papyrus/applettes/moteur_recherche/moteur_recherche_sphinx.php
226,6 → 226,10
unset($item['weight']);
}
 
function _actuNewerFirst($a,$b) {
return isset($a['date_creation']) && isset($b['date_creation']) ? strcmp($b['date_creation'], $a['date_creation']) : 0;
}
 
function sphinx_search($q = NULL, $page = 1) {
if(!$q) return array();
 
300,24 → 304,16
$docs['nvjfl-' . $v['id']] = array_merge($v, $res['nvjfl'][$v['id']]);
}
 
// sort
$sorted = _sortArrayByArray($docs, $ids_par_poids);
 
// sort
/*
// uncomment this:
print_r(array_keys($sorted); die;
$max = current($sorted);
$max = $max['weight'];
 
// then:
ddiff
<(mysql -h0 -P 9306 <<<"SELECT main_id FROM i_projet, i_spip, i_papyrus, i_bazar, i_coste, i_nvjfl WHERE MATCH('test') LIMIT 50;"|awk '{print $3}'|sed 1d) \
<(POST http://localhost/site:reseau<<<"more_motif=test&"|awk -F'=>' '{print $2}'|sed -e 's/ //g' -e '/^$/d')
if(isset($_GET['tri']) && $_GET['tri'] == 'date')
usort($sorted, '_actuNewerFirst');
 
// both should be equal.
// [ SELECT main_id, group_id FROM i_projet, i_spip, i_papyrus, i_bazar WHERE MATCH('test') LIMIT 50; ]
*/
 
$max = current($sorted);
$max = $max['weight'];
// transforme les clefs pour s'adapter aux templates existants
array_walk($sorted, '_weight2score', $max);
 
// var_dump($sorted);die;
339,3 → 335,17
Note: conversion côté client SQL:
mysql -h0 -P 9306 < <(iconv -f utf8 -t latin1 <<<"SELECT * FROM i_projet, i_spip, i_papyrus, i_bazar WHERE MATCH('journée');")
*/
 
/*
// test sorting
// uncomment this:
print_r(array_keys($sorted); die;
 
// then:
ddiff
<(mysql -h0 -P 9306 <<<"SELECT main_id FROM i_projet, i_spip, i_papyrus, i_bazar, i_coste, i_nvjfl WHERE MATCH('test') LIMIT 50;"|awk '{print $3}'|sed 1d) \
<(POST http://localhost/site:reseau<<<"more_motif=test&"|awk -F'=>' '{print $2}'|sed -e 's/ //g' -e '/^$/d')
// both should be equal.
// [ SELECT main_id, group_id FROM i_projet, i_spip, i_papyrus, i_bazar WHERE MATCH('test') LIMIT 50; ]
*/