mirror of
https://gitlab.aliens-lyon.fr/savrillo/gpens.git
synced 2026-03-18 06:01:02 +01:00
Merge branch 'searchengine'
This commit is contained in:
commit
95b3fea2ef
1
.gitignore
vendored
1
.gitignore
vendored
@ -2,3 +2,4 @@ svg-pan-zoom.min.js
|
|||||||
tinycolor-min.js
|
tinycolor-min.js
|
||||||
|
|
||||||
api/dbinit.php
|
api/dbinit.php
|
||||||
|
api/sallesNoms.index
|
||||||
|
|||||||
3
.gitmodules
vendored
Normal file
3
.gitmodules
vendored
Normal file
@ -0,0 +1,3 @@
|
|||||||
|
[submodule "api/tntsearch"]
|
||||||
|
path = api/tntsearch
|
||||||
|
url = git@github.com:teamtnt/tntsearch.git
|
||||||
@ -6,9 +6,8 @@ ini_set('display_startup_errors', 1);
|
|||||||
error_reporting(E_ALL);
|
error_reporting(E_ALL);
|
||||||
|
|
||||||
// Se connecte à la BDD (identifiants cachés)
|
// Se connecte à la BDD (identifiants cachés)
|
||||||
include 'dbinit.php';
|
// Charge les paramètres de tnt dans $tntconfig
|
||||||
|
include_once 'dbinit.php';
|
||||||
|
|
||||||
|
|
||||||
if(isset($_GET["salle"])) {
|
if(isset($_GET["salle"])) {
|
||||||
|
|
||||||
@ -54,35 +53,51 @@ if(isset($_GET["salle"])) {
|
|||||||
echo (json_encode($out));
|
echo (json_encode($out));
|
||||||
}
|
}
|
||||||
|
|
||||||
} else if (isset($_GET["research"])) {
|
} else if (isset($_GET["search"])) {
|
||||||
$research = $_GET["research"];
|
$searchText = $_GET["search"];
|
||||||
|
$rescount = isset($_GET["rescount"])?$_GET["rescount"]:7;
|
||||||
|
|
||||||
$stmt = $conn->prepare("SELECT salleID, nom FROM salleAlias WHERE MATCH nom AGAINST (? IN BOOLEAN MODE)");
|
include_once 'setupTntsearch.php';
|
||||||
$stmt->execute([$research]);
|
|
||||||
$res = $stmt->fetchAll();
|
$tnt->selectIndex("salleSearch.index");
|
||||||
|
$tnt->fuzziness = true;
|
||||||
|
$tnt->fuzzy_prefix_length = 2;
|
||||||
|
$tnt->fuzzy_max_expansions = 50;
|
||||||
|
$tnt->fuzzy_distance = 2; //represents the Levenshtein distance;
|
||||||
|
|
||||||
|
$res = $tnt->search($searchText,$rescount);
|
||||||
|
|
||||||
$out = array();
|
$out = array();
|
||||||
|
|
||||||
for($i=0;$i<count($res);$i++)
|
for($i=0; $i<count($res['ids']); $i++){
|
||||||
$out[$i] = array("id" => $res[$i]['salleID'], "name" => $res[$i]["nom"]);
|
$theid = $res['ids'][$i];
|
||||||
|
$stmt = $conn->prepare("SELECT nom FROM salleAlias WHERE salleID=?");
|
||||||
|
$stmt->execute([$theid]);
|
||||||
|
$resS = $stmt->fetchAll();
|
||||||
|
|
||||||
|
$nomz = array();
|
||||||
|
for($j=0;$j<count($resS);$j++)
|
||||||
|
$nomz[$j] = $resS[$j]['nom'];
|
||||||
|
|
||||||
|
$out[$theid] = array('noms' => $nomz);
|
||||||
|
}
|
||||||
|
|
||||||
|
for($i=0; $i<count($res["ids"]); $i++){
|
||||||
|
$theid = $res['ids'][$i];
|
||||||
|
$stmt = $conn->prepare("SELECT personne FROM locataires WHERE salleID=?");
|
||||||
|
$stmt->execute([$theid]);
|
||||||
|
$resL = $stmt->fetchAll();
|
||||||
|
|
||||||
|
$locatairez = array();
|
||||||
|
for($j=0;$j<count($resL);$j++)
|
||||||
|
$locatairez[$j] = $resL[$j]['personne'];
|
||||||
|
|
||||||
|
$out[$theid]['locataires'] = $locatairez;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
echo (json_encode($out));
|
echo (json_encode($out));
|
||||||
|
|
||||||
} else if (isset($_GET["salleLocSearch"])) {
|
} else {
|
||||||
|
|
||||||
$salleLocSearch = $_GET["salleLocSearch"];
|
|
||||||
|
|
||||||
$stmt = $conn->prepare("SELECT salleID, personne FROM `locataires` WHERE MATCH personne AGAINST (? IN BOOLEAN MODE)");
|
|
||||||
$stmt->execute([$salleLocSearch]);
|
|
||||||
$res = $stmt->fetchAll();
|
|
||||||
|
|
||||||
$out = array();
|
|
||||||
|
|
||||||
for($i=0;$i<count($res);$i++)
|
|
||||||
$out[$i] = array("salleID" => $res[$i]['salleID'], "personne" => $res[$i]["personne"]);
|
|
||||||
|
|
||||||
echo (json_encode($out));
|
|
||||||
|
|
||||||
}else {
|
|
||||||
echo "Je ne connais pas cette commande ...";
|
echo "Je ne connais pas cette commande ...";
|
||||||
}
|
}
|
||||||
|
|||||||
23
api/setupTntsearch.php
Normal file
23
api/setupTntsearch.php
Normal file
@ -0,0 +1,23 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
set_include_path(get_include_path() . PATH_SEPARATOR . './tntsearch/src/');
|
||||||
|
use TeamTNT\TNTSearch\TNTSearch;
|
||||||
|
|
||||||
|
include_once 'TNTSearch.php';
|
||||||
|
include_once 'Support/AbstractTokenizer.php';
|
||||||
|
include_once 'Support/TokenizerInterface.php';
|
||||||
|
include_once 'Support/Tokenizer.php';
|
||||||
|
include_once 'Support/Collection.php';
|
||||||
|
include_once 'FileReaders/FileReaderInterface.php';
|
||||||
|
include_once 'FileReaders/TextFileReader.php';
|
||||||
|
include_once 'Indexer/TNTIndexer.php';
|
||||||
|
include_once 'Stemmer/Stemmer.php';
|
||||||
|
include_once 'Stemmer/FrenchStemmer.php';
|
||||||
|
include_once 'Stemmer/NoStemmer.php';
|
||||||
|
include_once 'Connectors/ConnectorInterface.php';
|
||||||
|
include_once 'Connectors/Connector.php';
|
||||||
|
include_once 'Connectors/MySqlConnector.php';
|
||||||
|
|
||||||
|
$tnt = new TNTSearch;
|
||||||
|
|
||||||
|
$tnt->loadConfig($tntconfig);
|
||||||
1
api/tntsearch
Submodule
1
api/tntsearch
Submodule
@ -0,0 +1 @@
|
|||||||
|
Subproject commit 1fd7b79467dffe141de3691942d11127a21c2cbd
|
||||||
18
api/updateIndexes.php
Normal file
18
api/updateIndexes.php
Normal file
@ -0,0 +1,18 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
ini_set('display_errors', 1);
|
||||||
|
ini_set('display_startup_errors', 1);
|
||||||
|
error_reporting(E_ALL);
|
||||||
|
|
||||||
|
// Se connecte à la BDD (identifiants cachés)
|
||||||
|
// Charge les paramètres de tnt dans $tntconfig
|
||||||
|
include_once 'dbinit.php';
|
||||||
|
include_once 'setupTntsearch.php';
|
||||||
|
|
||||||
|
$indexer = $tnt->createIndex('salleSearch.index');
|
||||||
|
$indexer->query('(SELECT salleId AS id, nom AS searchText FROM salleAlias) UNION (SELECT salleId AS id, personne AS searchText FROM locataires)');
|
||||||
|
$indexer->setLanguage('french');
|
||||||
|
$indexer->run();
|
||||||
|
|
||||||
|
echo "<br/>";
|
||||||
|
echo "Mise à jour de l'index faite avec succès !";
|
||||||
10810
maps/M-MGN1-4.svg
10810
maps/M-MGN1-4.svg
File diff suppressed because one or more lines are too long
|
Before Width: | Height: | Size: 680 KiB After Width: | Height: | Size: 788 KiB |
Loading…
x
Reference in New Issue
Block a user